Added check for scene availability
This commit is contained in:
parent
0b7fef1027
commit
a06ae56817
|
|
@ -116,26 +116,32 @@ def writeToConfig(idx, page, component, description, extra):
|
||||||
|
|
||||||
def checkDomoticzStatus(config):
|
def checkDomoticzStatus(config):
|
||||||
domoticzDevices = []
|
domoticzDevices = []
|
||||||
|
domoticzScenes = []
|
||||||
try:
|
try:
|
||||||
result = json.loads(queryDomoticz("?type=devices&filter=all"))
|
result = json.loads(queryDomoticz("?type=devices&filter=all"))
|
||||||
|
resultScene = json.loads(queryDomoticz("?type=scenes&filter=all"))
|
||||||
except:
|
except:
|
||||||
print "Domoticz is not reachable."
|
print "Domoticz is not reachable."
|
||||||
sys.exit()
|
sys.exit()
|
||||||
for device in result["result"]:
|
for device in result["result"]:
|
||||||
domoticzDevices.append(device["idx"])
|
domoticzDevices.append(device["idx"])
|
||||||
configuredDevicesInDomoticz(config, domoticzDevices)
|
for device in resultScene["result"]:
|
||||||
|
domoticzScenes.append(device["idx"])
|
||||||
|
|
||||||
def configuredDevicesInDomoticz(config, domoticzDevices):
|
configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes)
|
||||||
|
#configuredDevicesInDomoticz(config, domoticzScenes)
|
||||||
|
|
||||||
|
def configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes):
|
||||||
for k, v in config.iteritems():
|
for k, v in config.iteritems():
|
||||||
if isinstance(v, dict):
|
if isinstance(v, dict):
|
||||||
configuredDevicesInDomoticz(v, domoticzDevices)
|
configuredDevicesInDomoticz(v, domoticzDevices, domoticzScenes)
|
||||||
else:
|
else:
|
||||||
if isinstance(v, int):
|
if isinstance(v, int):
|
||||||
if v not in domoticzDevices:
|
if v not in domoticzDevices and v not in domoticzScenes:
|
||||||
print "Device with " + v + " is not available in Domoticz"
|
print "Device with " + v + " is not available in Domoticz"
|
||||||
sys.exit()
|
sys.exit()
|
||||||
elif isinstance(v, list):
|
elif isinstance(v, list):
|
||||||
if (v[0].isdigit()) and (v[0] not in domoticzDevices):
|
if (v[0].isdigit()) and (v[0] not in domoticzDevices and v[0] not in domoticzScenes):
|
||||||
print "Device with " + v[0] + " is not available in Domoticz"
|
print "Device with " + v[0] + " is not available in Domoticz"
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue