How to get the IDX in bash ?
Moderator: leecollings
- warp
- Posts: 33
- Joined: Thursday 07 May 2015 12:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Fr
- Contact:
How to get the IDX in bash ?
How to get the IDX by the name of a device in bash?
Raspberry 2B:RaZberry Z-Wave+:Edimax EW-7811UN:Huawei E220 3G
4xQubino ZMNHCA2
Everspring SE812 & ST812
Mcohome MH-S411 & MH-S412
2xAEON LABS ZW-100
2xFibaro FGSD-002:Fibaro FGFS-101:Fibaro FGS-221 & KLF-050
4xQubino ZMNHCA2
Everspring SE812 & ST812
Mcohome MH-S411 & MH-S412
2xAEON LABS ZW-100
2xFibaro FGSD-002:Fibaro FGFS-101:Fibaro FGS-221 & KLF-050
-
- Posts: 40
- Joined: Friday 29 January 2016 16:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: How to get the IDX in bash ?
the best advice I can give is to use json connection: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
It is a very strong interface and good documented + a number of examples to start in the wiki
It is a very strong interface and good documented + a number of examples to start in the wiki
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: How to get the IDX in bash ?
Not really by name, but by sequence in a roomplan:
Part of a script I use to shutdown the NAS, except if one of these 2 switches is ON:
jq -r '.result[0].Status' = first switch in roomplan
jq -r '.result[1].Status' = second
...
Part of a script I use to shutdown the NAS, except if one of these 2 switches is ON:
jq -r '.result[0].Status' = first switch in roomplan
jq -r '.result[1].Status' = second
...
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"
- jvdz
- Posts: 2334
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: How to get the IDX in bash ?
This should work based on the devicename. Save in a file like getidx.sh:
Then run: sh getidx.sh "switchname"
Jos
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
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 784
- Joined: Wednesday 10 December 2014 13:06
- Target OS: Linux
- Domoticz version: beta
- Location: Bordeaux France
- Contact:
Re: How to get the IDX in bash ?
Wrap post the same in a french forum, dont say hello, thanx or please and this the same here....un minimum de politesse !
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
-
- Posts: 1
- Joined: Thursday 07 January 2016 16:17
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to get the IDX in bash ?
V. Nov
V
M n.
Verzonden vanaf mijn iPhone met Tapatalk
V
M n.
Verzonden vanaf mijn iPhone met Tapatalk
- warp
- Posts: 33
- Joined: Thursday 07 May 2015 12:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Fr
- Contact:
Re: How to get the IDX in bash ?
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 !
Il n'est pas n'nécessaire de me suivre a la trace pour me le faire remarquer !! C'est presque du harcèlement !

Raspberry 2B:RaZberry Z-Wave+:Edimax EW-7811UN:Huawei E220 3G
4xQubino ZMNHCA2
Everspring SE812 & ST812
Mcohome MH-S411 & MH-S412
2xAEON LABS ZW-100
2xFibaro FGSD-002:Fibaro FGFS-101:Fibaro FGS-221 & KLF-050
4xQubino ZMNHCA2
Everspring SE812 & ST812
Mcohome MH-S411 & MH-S412
2xAEON LABS ZW-100
2xFibaro FGSD-002:Fibaro FGFS-101:Fibaro FGS-221 & KLF-050
Who is online
Users browsing this forum: No registered users and 1 guest