Added function for an setpoint slider
This commit is contained in:
parent
979499fdfc
commit
d95db075f1
|
|
@ -36,6 +36,7 @@ Just one config is used to configure Domoboard. A example can be found the appli
|
||||||
- dimmer
|
- dimmer
|
||||||
- rgb
|
- rgb
|
||||||
- setpoint
|
- setpoint
|
||||||
|
- setpoint_slider
|
||||||
- pushon
|
- pushon
|
||||||
- pushoff
|
- pushoff
|
||||||
- group
|
- group
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@
|
||||||
Close Garage door = 567, pushoff
|
Close Garage door = 567, pushoff
|
||||||
Scene Home = 4, scene
|
Scene Home = 4, scene
|
||||||
Group kitchen lights = 5, group
|
Group kitchen lights = 5, group
|
||||||
|
Thermostaat_slider = 71, setpoint_slider, 18, 28
|
||||||
[[power_usage]]
|
[[power_usage]]
|
||||||
Totaal slaapkamer lamp = 12
|
Totaal slaapkamer lamp = 12
|
||||||
Totaal playstation = 71
|
Totaal playstation = 71
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,19 @@ function dimmerSlider(updateDimmers, block) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setpointSlider(updateSetpoints, block) {
|
||||||
|
$.each(updateSetpoints, function(i, setpoint) {
|
||||||
|
url = "/api?type=devices&rid=" + setpoint[0];
|
||||||
|
requestAPI(url, function(d) {
|
||||||
|
var percentage = parseInt(JSON.parse(d).result[0].Data);
|
||||||
|
$('#setpoint_slider' + setpoint[0] + "_block_" + block).slider({min:parseInt(setpoint[1]), max:parseInt(setpoint[2]), value: percentage}).on('slideStop', function(ev) {
|
||||||
|
changeSetpoint(setpoint[0], ev.value);
|
||||||
|
} ).data('slider');
|
||||||
|
$('#stpnt_' + setpoint[0] + "_block_" + block + '_track').css({'background-image': '-webkit-linear-gradient(top, #f9f9f9 0%, red 100%)', 'background-image': '-o-linear-gradient(top, #f9f9f9 0%, red 100%)', 'background-image': 'linear-gradient(to bottom, #f9f9f9 0%, red 100%)'});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function changeDimmerSlider(idx, value) {
|
function changeDimmerSlider(idx, value) {
|
||||||
var re = /dimmer_(\d+)_block_\d+/;
|
var re = /dimmer_(\d+)_block_\d+/;
|
||||||
match = re.exec(idx);
|
match = re.exec(idx);
|
||||||
|
|
@ -311,9 +324,6 @@ function modifyConfigButtonClicked(id) {
|
||||||
|
|
||||||
// Setpoint functions
|
// Setpoint functions
|
||||||
function changeSetpoint(idx, val) {
|
function changeSetpoint(idx, val) {
|
||||||
if (val.split('.')[1] == '0'){
|
|
||||||
val = val.split('.')[0];
|
|
||||||
}
|
|
||||||
requestAPI(flask_server + "/api?type=command¶m=setsetpoint&idx=" + idx + "&setpoint=" + val);
|
requestAPI(flask_server + "/api?type=command¶m=setsetpoint&idx=" + idx + "&setpoint=" + val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
<div><div style="float: left"><button id="groupon_{{v[1]}}_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[1]}}_block_{{count}}" class="btn btn-primary btn-circle btn-danger"> <li class="fa fa-power-off" aria-hidden="true"></i> </button></div></div>
|
<div><div style="float: left"><button id="groupon_{{v[1]}}_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[1]}}_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[2] %}
|
{% elif "scene" in v[2] %}
|
||||||
<button id="scene_{{v[1]}}_block_{{count}}" class="btn btn-primary btn-circle"> <li class="fa fa-power-off" aria-hidden="true"></i> </button>
|
<button id="scene_{{v[1]}}_block_{{count}}" class="btn btn-primary btn-circle"> <li class="fa fa-power-off" aria-hidden="true"></i> </button>
|
||||||
{% elif "setpoint" in v[2] %}
|
{% elif v[2] == "setpoint" %}
|
||||||
<div>
|
<div>
|
||||||
<div style="float: left; margin-right: 5px"><h1 id="setpoint_{{v[1]}}_block_{{count}}" style="font-size: 16px;"></h1></div>
|
<div style="float: left; margin-right: 5px"><h1 id="setpoint_{{v[1]}}_block_{{count}}" style="font-size: 16px;"></h1></div>
|
||||||
<div style="float: left">
|
<div style="float: left">
|
||||||
|
|
@ -43,6 +43,8 @@
|
||||||
<div style=""><i onclick="changeDown({{ v[1] }}, {{count}})" class="fa fa-arrow-down" style="font-size: 13px; cursor: pointer;" aria-hidden="true"></i></div>
|
<div style=""><i onclick="changeDown({{ v[1] }}, {{count}})" class="fa fa-arrow-down" style="font-size: 13px; cursor: pointer;" aria-hidden="true"></i></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% elif "setpoint_slider" in v[2] %}
|
||||||
|
<input id="setpoint_slider{{v[1]}}_block_{{count}}" data-slider-id='stpnt_{{v[1]}}_block_{{count}}' type="text" state="on" data-slider-min="{{v[3]}}" data-slider-max="{{v[4]}}" data-slider-step="1" data-slider-value="" />
|
||||||
{% elif "rgb" in v[2] %}
|
{% elif "rgb" in v[2] %}
|
||||||
<input id="dimmer_{{v[1]}}_block_{{count}}" data-slider-id='dim_{{v[1]}}_block_{{count}}' type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="14" />
|
<input id="dimmer_{{v[1]}}_block_{{count}}" data-slider-id='dim_{{v[1]}}_block_{{count}}' type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="14" />
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
@ -95,6 +97,7 @@ $(document).ready(function() {
|
||||||
var updateSwitches_block_{{count}}=[];
|
var updateSwitches_block_{{count}}=[];
|
||||||
var updateDimmers_block_{{count}}=[];
|
var updateDimmers_block_{{count}}=[];
|
||||||
var updateSetpoints_block_{{count}}=[];
|
var updateSetpoints_block_{{count}}=[];
|
||||||
|
var updateSetpoint_sliders_block_{{count}}=[];
|
||||||
|
|
||||||
{% for k, v in blockArray[count]["switches"].iteritems() %}
|
{% for k, v in blockArray[count]["switches"].iteritems() %}
|
||||||
|
|
||||||
|
|
@ -131,6 +134,8 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
{% elif (v[2] == "setpoint") %}
|
{% elif (v[2] == "setpoint") %}
|
||||||
updateSetpoints_block_{{count}}.push("{{v[1]}}");
|
updateSetpoints_block_{{count}}.push("{{v[1]}}");
|
||||||
|
{% elif (v[2] == "setpoint_slider") %}
|
||||||
|
updateSetpoint_sliders_block_{{count}}.push(["{{v[1]}}", "{{v[3]}}", "{{v[4]}}"]);
|
||||||
{% elif (v[2] == "dimmer" or v[2] == "rgb") %}
|
{% elif (v[2] == "dimmer" or v[2] == "rgb") %}
|
||||||
$('#dim_{{count}}').click(function(e) {
|
$('#dim_{{count}}').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
@ -142,8 +147,11 @@ $(document).ready(function() {
|
||||||
refreshSwitches(updateSwitches_block_{{count}}, {{count}});
|
refreshSwitches(updateSwitches_block_{{count}}, {{count}});
|
||||||
refreshSetpoints(updateSetpoints_block_{{count}}, {{count}});
|
refreshSetpoints(updateSetpoints_block_{{count}}, {{count}});
|
||||||
dimmerSlider(updateDimmers_block_{{count}}, {{count}});
|
dimmerSlider(updateDimmers_block_{{count}}, {{count}});
|
||||||
|
setpointSlider(updateSetpoint_sliders_block_{{count}}, {{count}});
|
||||||
|
|
||||||
setInterval(refreshSwitches, 9000, updateSwitches_block_{{count}}, {{count}});
|
setInterval(refreshSwitches, 9000, updateSwitches_block_{{count}}, {{count}});
|
||||||
setInterval(dimmerSlider, 9000, updateDimmers_block_{{count}}, {{count}});
|
setInterval(dimmerSlider, 9000, updateDimmers_block_{{count}}, {{count}});
|
||||||
|
setInterval(setpointSlider, 9000, updateSetpoint_sliders_block_{{count}}, {{count}});
|
||||||
setInterval(refreshSetpoints, 9000, updateSetpoints_block_{{count}}, {{count}});
|
setInterval(refreshSetpoints, 9000, updateSetpoints_block_{{count}}, {{count}});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue