diff --git a/README.md b/README.md index ceaf7ca..8fda4c0 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ Just one config is used to configure Domoboard. A example can be found the appli - setpoint - pushon - pushoff + - group + - scene - camera - weather - news diff --git a/example.conf b/example.conf index 5835dd7..0135e7b 100644 --- a/example.conf +++ b/example.conf @@ -52,6 +52,8 @@ Slaapkamer lightstrip = 12, rgb Open Garage door = 456, pushon Close Garage door = 567, pushoff + Scene Home = 4, scene + Group kitchen lights = 5, group [[power_usage]] Totaal slaapkamer lamp = 12 Totaal playstation = 71 diff --git a/modules/api.py b/modules/api.py index 4300d2a..e16ef7d 100644 --- a/modules/api.py +++ b/modules/api.py @@ -116,28 +116,29 @@ def writeToConfig(idx, page, component, description, extra): def checkDomoticzStatus(config): domoticzDevices = [] + domoticzScenes = [] try: result = json.loads(queryDomoticz("?type=devices&filter=all")) + resultScene = json.loads(queryDomoticz("?type=scenes&filter=all")) except: - print "Domoticz is not reachable." - sys.exit() + sys.exit("Domoticz is not reachable.") for device in result["result"]: domoticzDevices.append(device["idx"]) - configuredDevicesInDomoticz(config, domoticzDevices) + for device in resultScene["result"]: + domoticzScenes.append(device["idx"]) + configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes) -def configuredDevicesInDomoticz(config, domoticzDevices): +def configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes): for k, v in config.iteritems(): if isinstance(v, dict): - configuredDevicesInDomoticz(v, domoticzDevices) + configuredDevicesInDomoticz(v, domoticzDevices, domoticzScenes) else: if isinstance(v, int): - if v not in domoticzDevices: - print "Device with " + v + " is not available in Domoticz" - sys.exit() + if v not in domoticzDevices and v not in domoticzScenes: + sys.exit("Device and/or scene with IDX {} is not available in Domoticz".format(v)) elif isinstance(v, list): - if (v[0].isdigit()) and (v[0] not in domoticzDevices): - print "Device with " + v[0] + " is not available in Domoticz" - sys.exit() + if (v[0].isdigit()) and (v[0] not in domoticzDevices and v[0] not in domoticzScenes): + sys.exit("Device and/or scene with IDX {} is not available in Domoticz".format(v[0])) def getPluginDict(): global indexes diff --git a/static/js/domoboard.js b/static/js/domoboard.js index 51fdd52..4c54582 100644 --- a/static/js/domoboard.js +++ b/static/js/domoboard.js @@ -31,6 +31,13 @@ function changePush(idx, action) { } } +function changeScene(idx, action) { + if (action == 'on') { + requestAPI(flask_server + "/api?type=command¶m=switchscene&idx=" + idx + "&switchcmd=On" ); + } else { + requestAPI(flask_server + "/api?type=command¶m=switchscene&idx=" + idx + "&switchcmd=Off" ); + } +} function refreshSwitches(updateSwitches, block) { $.each(updateSwitches, function (i, switchID) { diff --git a/templates/switches.html b/templates/switches.html index 635f67d..0491ae6 100644 --- a/templates/switches.html +++ b/templates/switches.html @@ -23,14 +23,20 @@ {% elif "dimmer" in v[1] %} {% elif "pushon" in v[1] %} - + {% elif "pushoff" in v[1] %} - + + {% elif "group" in v[1] %} +