From 2df9bdc8a0630457ff732a34609e0c5657752500 Mon Sep 17 00:00:00 2001 From: Squandor Date: Tue, 3 Jan 2017 09:39:54 +0100 Subject: [PATCH 1/7] Added scene and group functionality --- example.conf | 2 ++ static/js/domoboard.js | 7 +++++++ templates/switches.html | 23 +++++++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) 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/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..bfdc042 100644 --- a/templates/switches.html +++ b/templates/switches.html @@ -23,9 +23,13 @@ {% elif "dimmer" in v[1] %} {% elif "pushon" in v[1] %} - + {% elif "pushoff" in v[1] %} - + + {% elif "group" in v[1] %} +
+ {% elif "scene" in v[1] %} + {% elif "setpoint" in v[1] %}

@@ -105,6 +109,21 @@ $(document).ready(function() { e.preventDefault(); changePush({{v[0]}}, 'off'); }); + {% elif (v[1] == "group") or (v[1] == "scene") %} + $('button[id="groupon_{{v[0]}}_block_{{count}}"]').click(function(e) { + e.preventDefault(); + console.log('group on'); + changeScene({{v[0]}}, 'on'); + }); + $('button[id="groupoff_{{v[0]}}_block_{{count}}"]').click(function(e) { + e.preventDefault(); + console.log('group off'); + changeScene({{v[0]}}, 'off'); + }); + $('button[id="scene_{{v[0]}}_block_{{count}}"]').click(function(e) { + e.preventDefault(); + changeScene({{v[0]}}, 'on'); + }); {% elif (v[1] == "setpoint") %} updateSetpoints_block_{{count}}.push("{{v[0]}}"); {% elif (v[1] == "dimmer" or v[1] == "rgb") %} From 0b7fef1027a0d3c60e2f9f3a9e3073f078d022eb Mon Sep 17 00:00:00 2001 From: Squandor Date: Tue, 3 Jan 2017 13:02:36 +0100 Subject: [PATCH 2/7] Added scene and group to the Switches list --- README.md | 2 ++ 1 file changed, 2 insertions(+) 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 From a06ae56817c57983bca05643ba871b549912268e Mon Sep 17 00:00:00 2001 From: squandor Date: Tue, 3 Jan 2017 19:13:28 +0100 Subject: [PATCH 3/7] Added check for scene availability --- modules/api.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/api.py b/modules/api.py index 4300d2a..5b20489 100644 --- a/modules/api.py +++ b/modules/api.py @@ -116,26 +116,32 @@ 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() for device in result["result"]: 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(): if isinstance(v, dict): - configuredDevicesInDomoticz(v, domoticzDevices) + configuredDevicesInDomoticz(v, domoticzDevices, domoticzScenes) else: 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" sys.exit() 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" sys.exit() From 249cbab95c01cb49d5dbf6a66e767290626b67a8 Mon Sep 17 00:00:00 2001 From: squandor Date: Tue, 3 Jan 2017 19:48:58 +0100 Subject: [PATCH 4/7] Fixed design bug of setpoint --- templates/switches.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/switches.html b/templates/switches.html index bfdc042..0669aa6 100644 --- a/templates/switches.html +++ b/templates/switches.html @@ -33,8 +33,10 @@ {% elif "setpoint" in v[1] %}

-
-
+
+
+
+
{% elif "rgb" in v[1] %}   From e5f421bb49f8ad63cbc69f08f7597772bf260ca1 Mon Sep 17 00:00:00 2001 From: wez3 Date: Tue, 3 Jan 2017 20:14:00 +0100 Subject: [PATCH 5/7] Some code tweaks --- modules/api.py | 11 +++-------- templates/switches.html | 2 -- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/modules/api.py b/modules/api.py index 5b20489..e16ef7d 100644 --- a/modules/api.py +++ b/modules/api.py @@ -121,15 +121,12 @@ def checkDomoticzStatus(config): 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"]) for device in resultScene["result"]: domoticzScenes.append(device["idx"]) - configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes) - #configuredDevicesInDomoticz(config, domoticzScenes) def configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes): for k, v in config.iteritems(): @@ -138,12 +135,10 @@ def configuredDevicesInDomoticz(config, domoticzDevices, domoticzScenes): else: if isinstance(v, int): if v not in domoticzDevices and v not in domoticzScenes: - print "Device with " + v + " is not available in Domoticz" - sys.exit() + 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 and v[0] not in domoticzScenes): - print "Device with " + v[0] + " is not available in Domoticz" - sys.exit() + sys.exit("Device and/or scene with IDX {} is not available in Domoticz".format(v[0])) def getPluginDict(): global indexes diff --git a/templates/switches.html b/templates/switches.html index 0669aa6..0491ae6 100644 --- a/templates/switches.html +++ b/templates/switches.html @@ -114,12 +114,10 @@ $(document).ready(function() { {% elif (v[1] == "group") or (v[1] == "scene") %} $('button[id="groupon_{{v[0]}}_block_{{count}}"]').click(function(e) { e.preventDefault(); - console.log('group on'); changeScene({{v[0]}}, 'on'); }); $('button[id="groupoff_{{v[0]}}_block_{{count}}"]').click(function(e) { e.preventDefault(); - console.log('group off'); changeScene({{v[0]}}, 'off'); }); $('button[id="scene_{{v[0]}}_block_{{count}}"]').click(function(e) { From 7838607960c24212de1b686fcb9ce5bc8dfb8cb8 Mon Sep 17 00:00:00 2001 From: felix63 Date: Tue, 3 Jan 2017 21:49:08 +0100 Subject: [PATCH 6/7] New template for showing dutch TV data This is a simple template adding a block containing a external iFrame giving info about actual TV-information for Dutch TV. --- templates/tvgids.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 templates/tvgids.html diff --git a/templates/tvgids.html b/templates/tvgids.html new file mode 100644 index 0000000..f7d4860 --- /dev/null +++ b/templates/tvgids.html @@ -0,0 +1,17 @@ +
+
+
+

TV-Gids

+ + +
+
+
+ +
-
+