diff --git a/LaundryServer.py b/LaundryServer.py index 57edb7f..c0a2740 100644 --- a/LaundryServer.py +++ b/LaundryServer.py @@ -18,7 +18,7 @@ switchMapping = { } -loadedSwitchStates = ['x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7'] +loadedSwitchStates = ['on', 'on', 'off', 'x3', 'x4', 'x5', 'x6', 'x7'] #def on_message(client, userdata, msg): diff --git a/index.html b/index.html index 2e9cfe9..6909c26 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,7 @@ $.ajaxSetup({ async: false }); + $("#flip-checkbox-1").flipswitch({"defaults": true}); var switchMapping = $.getJSON('http://' + serverAddress + '/switchMapping').responseJSON; var firstListItem = $("li:first", "#switchlist"); for (var key in switchMapping) { @@ -37,9 +38,19 @@ }); $(".switchlink").click(function() { var v = $(this).attr("id"); + $("#target").text(v); var w = $("span:first", this).text(); $("#dialogTitle").text(w); - $("#target").text(v); + var x = $("span:last", this).text(); + console.debug(x); + if (x == 'on') { + console.debug('x:on'); + $("#flip-checkbox-1").prop('checked', true); + } else { + console.debug('x:off'); + $("#flip-checkbox-1").prop('checked', false); + } + $("#flip-checkbox-1").flipswitch( "refresh" ); }); function updateState() { for (var key in switchMapping) {