diff --git a/static/js/domoboard.js b/static/js/domoboard.js index 22a0f6a..6fec00a 100644 --- a/static/js/domoboard.js +++ b/static/js/domoboard.js @@ -22,6 +22,18 @@ function changeSwitch(checkboxElem, idx) { } } +// Dimmer functions +function changeDimmer(checkboxElem, idx) { + var chkurl = "/api?type=devices&rid=" + idx; + requestAPI(flask_server + chkurl, function(d) { + _json = JSON.parse(d); + if (_json['result'][0]['Data'] != 'Off') { + requestAPI(flask_server + "/api?type=command¶m=switchlight&idx=" + idx + "&switchcmd=Off&level=0"); + } else { + requestAPI(flask_server + "/api?type=command¶m=switchlight&idx=" + idx + "&switchcmd=On&level=0"); + } + }); +} // Switch functions function changePush(idx, action) { if (action == 'on') { diff --git a/templates/switches.html b/templates/switches.html index 0491ae6..f3295b3 100644 --- a/templates/switches.html +++ b/templates/switches.html @@ -16,12 +16,16 @@