Some code tweaks
This commit is contained in:
parent
249cbab95c
commit
e5f421bb49
|
|
@ -121,15 +121,12 @@ def checkDomoticzStatus(config):
|
||||||
result = json.loads(queryDomoticz("?type=devices&filter=all"))
|
result = json.loads(queryDomoticz("?type=devices&filter=all"))
|
||||||
resultScene = json.loads(queryDomoticz("?type=scenes&filter=all"))
|
resultScene = json.loads(queryDomoticz("?type=scenes&filter=all"))
|
||||||
except:
|
except:
|
||||||
print "Domoticz is not reachable."
|
sys.exit("Domoticz is not reachable.")
|
||||||
sys.exit()
|
|
||||||
for device in result["result"]:
|
for device in result["result"]:
|
||||||
domoticzDevices.append(device["idx"])
|
domoticzDevices.append(device["idx"])
|
||||||
for device in resultScene["result"]:
|
for device in resultScene["result"]:
|
||||||
domoticzScenes.append(device["idx"])
|
domoticzScenes.append(device["idx"])
|
||||||
|
|
||||||
configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes)
|
configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes)
|
||||||
#configuredDevicesInDomoticz(config, domoticzScenes)
|
|
||||||
|
|
||||||
def configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes):
|
def configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes):
|
||||||
for k, v in config.iteritems():
|
for k, v in config.iteritems():
|
||||||
|
|
@ -138,12 +135,10 @@ def configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes):
|
||||||
else:
|
else:
|
||||||
if isinstance(v, int):
|
if isinstance(v, int):
|
||||||
if v not in domoticzDevices and v not in domoticzScenes:
|
if v not in domoticzDevices and v not in domoticzScenes:
|
||||||
print "Device with " + v + " is not available in Domoticz"
|
sys.exit("Device and/or scene with IDX {} is not available in Domoticz".format(v))
|
||||||
sys.exit()
|
|
||||||
elif isinstance(v, list):
|
elif isinstance(v, list):
|
||||||
if (v[0].isdigit()) and (v[0] not in domoticzDevices and v[0] not in domoticzScenes):
|
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"
|
sys.exit("Device and/or scene with IDX {} is not available in Domoticz".format(v[0]))
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
def getPluginDict():
|
def getPluginDict():
|
||||||
global indexes
|
global indexes
|
||||||
|
|
|
||||||
|
|
@ -114,12 +114,10 @@ $(document).ready(function() {
|
||||||
{% elif (v[1] == "group") or (v[1] == "scene") %}
|
{% elif (v[1] == "group") or (v[1] == "scene") %}
|
||||||
$('button[id="groupon_{{v[0]}}_block_{{count}}"]').click(function(e) {
|
$('button[id="groupon_{{v[0]}}_block_{{count}}"]').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log('group on');
|
|
||||||
changeScene({{v[0]}}, 'on');
|
changeScene({{v[0]}}, 'on');
|
||||||
});
|
});
|
||||||
$('button[id="groupoff_{{v[0]}}_block_{{count}}"]').click(function(e) {
|
$('button[id="groupoff_{{v[0]}}_block_{{count}}"]').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log('group off');
|
|
||||||
changeScene({{v[0]}}, 'off');
|
changeScene({{v[0]}}, 'off');
|
||||||
});
|
});
|
||||||
$('button[id="scene_{{v[0]}}_block_{{count}}"]').click(function(e) {
|
$('button[id="scene_{{v[0]}}_block_{{count}}"]').click(function(e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue