How to get the IDX in bash ?
Posted: Friday 12 February 2016 11:45
How to get the IDX by the name of a device in bash?
Join 16,000+ members discussing home automation with Domoticz. Get help with Zigbee, ZWave, MQTT, scripting, and 150+ integrations
https://forum.domoticz.com/
Code: Select all
#!/usr/bin/bash
DOMOTICZ=`curl -s "http://192.168.0.8:8080/json.htm?type=devices&used=true&plan=6"`
KODI=`echo $DOMOTICZ | jq -r '.result[0].Status'`
if [[ $KODI = "On" ]]; then log "Kodi online, exiting"; exit; fi
log "Kodi Offline"
TOBI=`echo $DOMOTICZ | jq -r '.result[1].Status'`
if [[ $TOBI = "On" ]]; then log "TOBI online, exiting"; exit; fi
log "TOBI Offline"
Code: Select all
#!/bin/bash
#--Get Domotics Device
IDX=`curl -s 'http://127.0.0.1:8080/json.htm?type=devices&order=name' | /usr/local/bin/jq -r '.result[]|select(.Name == "'$1'")|.idx'`
if [ "$IDX" = "" ]; then
echo "Switchname:$1 not found"
else
echo "Switchname:$1 has IDX:$IDX"
fi
Désolé d'avoir oublié de dire bonjour, je pense que cela a du surement t'arriver aussi !deennoo wrote:Wrap post the same in a french forum, dont say hello, thanx or please and this the same here....un minimum de politesse !