Added scene and group functionality
This commit is contained in:
parent
3ec0440e2d
commit
2df9bdc8a0
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
function refreshSwitches(updateSwitches, block) {
|
||||||
$.each(updateSwitches, function (i, switchID) {
|
$.each(updateSwitches, function (i, switchID) {
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,13 @@
|
||||||
{% 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"> <li class="fa fa-power-off" aria-hidden="true"></i> </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"> <li class="fa fa-power-off" aria-hidden="true"></i> </button>
|
||||||
|
{% elif "group" in v[1] %}
|
||||||
|
<div><div style="float: left"><button id="groupon_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle"> <li class="fa fa-power-off" aria-hidden="true"></i> </button></div><div style="padding-left: 20px; float: left"><button id="groupoff_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle btn-danger"> <li class="fa fa-power-off" aria-hidden="true"></i> </button></div></div>
|
||||||
|
{% elif "scene" in v[1] %}
|
||||||
|
<button id="scene_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle"> <li class="fa fa-power-off" aria-hidden="true"></i> </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>
|
||||||
|
|
@ -105,6 +109,21 @@ $(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();
|
||||||
|
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") %}
|
{% 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") %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue