RZL: Add on/off button to kitchen light

This commit is contained in:
uwap 2018-04-08 13:19:24 +02:00
parent 72021aa83c
commit 02be6701be
2 changed files with 12 additions and 1 deletions

View file

@ -522,6 +522,15 @@ const config : Config = {
position: [325, 407], position: [325, 407],
icon: "ceiling-light", icon: "ceiling-light",
ui: [ ui: [
{
type: "toggle",
on: 50,
off: 0,
toggled: n => n > 0,
topic: "kitchen_light_brightness",
text: "Ein/Ausschalten",
icon: "power"
},
{ {
type: "slider", type: "slider",
min: 0, min: 0,

View file

@ -122,7 +122,9 @@ export class Toggle extends UiControl<UIToggle> {
if (this.isEnabled()) { if (this.isEnabled()) {
const control = this.props.item; const control = this.props.item;
const toggled = this.isToggled(); const toggled = this.isToggled();
const next = toggled ? (control.off || "off") : (control.on || "on"); const on = control.on == null ? "on" : control.on;
const off = control.off == null ? "off" : control.off;
const next = toggled ? off : on;
this.changeState(next); this.changeState(next);
} }
} }