diff --git a/README.md b/README.md index 286d119..3afb92f 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Just one config is used to configure Domoboard. A example can be found the appli - dimmer - rgb - setpoint + - setpoint_slider - pushon - pushoff - group diff --git a/example.conf b/example.conf index 94232d0..840a8a7 100644 --- a/example.conf +++ b/example.conf @@ -53,6 +53,7 @@ Close Garage door = 567, pushoff Scene Home = 4, scene Group kitchen lights = 5, group + Thermostaat_slider = 71, setpoint_slider, 18, 28 [[power_usage]] Totaal slaapkamer lamp = 12 Totaal playstation = 71 diff --git a/static/js/domoboard.js b/static/js/domoboard.js index 0731dc5..e067d26 100644 --- a/static/js/domoboard.js +++ b/static/js/domoboard.js @@ -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) { var re = /dimmer_(\d+)_block_\d+/; match = re.exec(idx); @@ -311,9 +324,6 @@ function modifyConfigButtonClicked(id) { // Setpoint functions 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); } diff --git a/templates/switches.html b/templates/switches.html index 3d7d82c..b5bf493 100644 --- a/templates/switches.html +++ b/templates/switches.html @@ -35,7 +35,7 @@