Merge pull request #35 from wez3/develop

Develop -> Master
This commit is contained in:
Squandor 2017-01-03 22:59:01 +01:00 committed by GitHub
commit 853e422084
6 changed files with 63 additions and 15 deletions

View File

@ -33,6 +33,8 @@ Just one config is used to configure Domoboard. A example can be found the appli
- setpoint - setpoint
- pushon - pushon
- pushoff - pushoff
- group
- scene
- camera - camera
- weather - weather
- news - news

View File

@ -52,6 +52,8 @@
Slaapkamer lightstrip = 12, rgb Slaapkamer lightstrip = 12, rgb
Open Garage door = 456, pushon Open Garage door = 456, pushon
Close Garage door = 567, pushoff Close Garage door = 567, pushoff
Scene Home = 4, scene
Group kitchen lights = 5, group
[[power_usage]] [[power_usage]]
Totaal slaapkamer lamp = 12 Totaal slaapkamer lamp = 12
Totaal playstation = 71 Totaal playstation = 71

View File

@ -116,28 +116,29 @@ 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." 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"])
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(): 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" 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): 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

View File

@ -31,6 +31,13 @@ function changePush(idx, action) {
} }
} }
function changeScene(idx, action) {
if (action == 'on') {
requestAPI(flask_server + "/api?type=command&param=switchscene&idx=" + idx + "&switchcmd=On" );
} else {
requestAPI(flask_server + "/api?type=command&param=switchscene&idx=" + idx + "&switchcmd=Off" );
}
}
function refreshSwitches(updateSwitches, block) { function refreshSwitches(updateSwitches, block) {
$.each(updateSwitches, function (i, switchID) { $.each(updateSwitches, function (i, switchID) {

View File

@ -23,14 +23,20 @@
{% elif "dimmer" in v[1] %} {% elif "dimmer" in v[1] %}
<input id="dimmer_{{v[0]}}_block_{{count}}" data-slider-id='dimmer_{{v[0]}}' type="text" test={{ v[1] }} data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="14" /> <input id="dimmer_{{v[0]}}_block_{{count}}" data-slider-id='dimmer_{{v[0]}}' type="text" test={{ v[1] }} data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="14" />
{% elif "pushon" in v[1] %} {% elif "pushon" in v[1] %}
<button id="push_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle">On</button> <button id="push_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button>
{% elif "pushoff" in v[1] %} {% elif "pushoff" in v[1] %}
<button id="push_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle">Off</button> <button id="push_{{v[0]}}_block_{{count}}" class="btn btn-danger btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button>
{% elif "group" in v[1] %}
<div><div style="float: left"><button id="groupon_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button></div><div style="padding-left: 20px; float: left"><button id="groupoff_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle btn-danger">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button></div></div>
{% elif "scene" in v[1] %}
<button id="scene_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button>
{% elif "setpoint" in v[1] %} {% elif "setpoint" in v[1] %}
<div> <div>
<div style="float: left; margin-right: 5px"><h1 id="setpoint_{{v[0]}}_block_{{count}}" style="font-size: 16px;"></h1></div> <div style="float: left; margin-right: 5px"><h1 id="setpoint_{{v[0]}}_block_{{count}}" style="font-size: 16px;"></h1></div>
<div style=""><i onclick="changeUp({{ v[0] }}, {{count}})" class="fa fa-arrow-up" style="font-size: 13px; cursor: pointer;" aria-hidden="true"></i></div> <div style="float: left">
<div style=""><i onclick="changeDown({{ v[0] }}, {{count}})" class="fa fa-arrow-down" style="font-size: 13px; cursor: pointer;" aria-hidden="true"></i></div> <div style=""><i onclick="changeUp({{ v[0] }}, {{count}})" class="fa fa-arrow-up" style="font-size: 13px; cursor: pointer;" aria-hidden="true"></i></div>
<div style=""><i onclick="changeDown({{ v[0] }}, {{count}})" class="fa fa-arrow-down" style="font-size: 13px; cursor: pointer;" aria-hidden="true"></i></div>
</div>
</div> </div>
{% elif "rgb" in v[1] %} {% elif "rgb" in v[1] %}
&nbsp;<input id="dimmer_{{v[0]}}_block_{{count}}" data-slider-id='dimmer_{{v[0]}}' type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="14" /> &nbsp;<input id="dimmer_{{v[0]}}_block_{{count}}" data-slider-id='dimmer_{{v[0]}}' type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="14" />
@ -105,6 +111,19 @@ $(document).ready(function() {
e.preventDefault(); e.preventDefault();
changePush({{v[0]}}, 'off'); changePush({{v[0]}}, 'off');
}); });
{% elif (v[1] == "group") or (v[1] == "scene") %}
$('button[id="groupon_{{v[0]}}_block_{{count}}"]').click(function(e) {
e.preventDefault();
changeScene({{v[0]}}, 'on');
});
$('button[id="groupoff_{{v[0]}}_block_{{count}}"]').click(function(e) {
e.preventDefault();
changeScene({{v[0]}}, 'off');
});
$('button[id="scene_{{v[0]}}_block_{{count}}"]').click(function(e) {
e.preventDefault();
changeScene({{v[0]}}, 'on');
});
{% elif (v[1] == "setpoint") %} {% elif (v[1] == "setpoint") %}
updateSetpoints_block_{{count}}.push("{{v[0]}}"); updateSetpoints_block_{{count}}.push("{{v[0]}}");
{% elif (v[1] == "dimmer" or v[1] == "rgb") %} {% elif (v[1] == "dimmer" or v[1] == "rgb") %}

17
templates/tvgids.html Normal file
View File

@ -0,0 +1,17 @@
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>TV-Gids </h2>
<ul class="nav navbar-right panel_toolbox">
<li><a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div id="tvgids" style="height: 450px;">
<iframe frameborder=0 style="overflow: hidden; position: relative; height: 100%; width: 100%;" src='https://www.tvgids24.nl/gadget'/></iframe>
</div>
</div>
</div>