#8 Relais ein / ausschalten von Ocotprint aus
- Toggle Button anzeigen und Events eingebaut - Api funktionen für Relais ein / aus und toggle implementiert
This commit is contained in:
@ -32,6 +32,20 @@
|
||||
display:none;
|
||||
}
|
||||
|
||||
.mystromToggleButton {
|
||||
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
|
||||
display: block;
|
||||
height: 100%;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
margin-left: 20px;
|
||||
margin-right: 20px;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
background-color: #eb0000;
|
||||
}
|
||||
|
||||
#touch body #tabs #sidebar_plugin_mystromswitch_wrapper_link a:before, #touch body #navbar #all_touchui_settings #sidebar_plugin_mystromswitch_wrapper_link a:before,#touch body #tabs #sidebar_plugin_mystromswitch_wrapper_link2 a:before, #touch body #navbar #all_touchui_settings #sidebar_plugin_mystromswitch_wrapper_link2 a:before {
|
||||
content: "\f011";
|
||||
}
|
||||
|
@ -9,6 +9,21 @@ $(function() {
|
||||
self.mystromswitchEnabled = ko.observable();
|
||||
self.mystromswitchPowerValue = document.getElementById("mystromswitchPowerValue")
|
||||
|
||||
self.mystromToggleButton = document.getElementById("myStromRelaisToggleButton")
|
||||
|
||||
self.onToggleRelayEvent = function(){
|
||||
$.ajax({
|
||||
url: API_BASEURL + "plugin/mystromswitch",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: JSON.stringify({
|
||||
command: "toggleRelais",
|
||||
}),
|
||||
contentType: "application/json; charset=UTF-8"
|
||||
})
|
||||
}
|
||||
self.mystromToggleButton.addEventListener("click",self.onToggleRelayEvent)
|
||||
|
||||
self.onmystromswitchEvent = function() {
|
||||
if (self.mystromswitchEnabled()) {
|
||||
$.ajax({
|
||||
@ -16,8 +31,7 @@ $(function() {
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: JSON.stringify({
|
||||
command: "enable",
|
||||
eventView : false
|
||||
command: "enableRelais",
|
||||
}),
|
||||
contentType: "application/json; charset=UTF-8"
|
||||
})
|
||||
@ -27,8 +41,7 @@ $(function() {
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: JSON.stringify({
|
||||
command: "disable",
|
||||
eventView : false
|
||||
command: "disableRelais",
|
||||
}),
|
||||
contentType: "application/json; charset=UTF-8"
|
||||
})
|
||||
@ -42,9 +55,11 @@ $(function() {
|
||||
return;
|
||||
}
|
||||
self.mystromswitchEnabled(data.mystromswitchEnabled);
|
||||
if (data.power != null) {
|
||||
self.mystromswitchPowerValue.innerHTML = "Power Consumption "+data.power.toFixed(2)+"W"
|
||||
}
|
||||
if(data.relay == false){
|
||||
self.mystromswitchPowerValue.innerHTML = "Relay is off";
|
||||
} else if (data.power != null) {
|
||||
self.mystromswitchPowerValue.innerHTML = "Power Consumption "+data.power.toFixed(1)+"W";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user