From 02be6701beb747ee031a0f18e32fa7b361aec853 Mon Sep 17 00:00:00 2001 From: uwap Date: Sun, 8 Apr 2018 13:19:24 +0200 Subject: [PATCH] RZL: Add on/off button to kitchen light --- config/rzl.js | 9 +++++++++ src/components/UiItemList/UiItem.js | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config/rzl.js b/config/rzl.js index 25c7422..556c62e 100644 --- a/config/rzl.js +++ b/config/rzl.js @@ -522,6 +522,15 @@ const config : Config = { position: [325, 407], icon: "ceiling-light", ui: [ + { + type: "toggle", + on: 50, + off: 0, + toggled: n => n > 0, + topic: "kitchen_light_brightness", + text: "Ein/Ausschalten", + icon: "power" + }, { type: "slider", min: 0, diff --git a/src/components/UiItemList/UiItem.js b/src/components/UiItemList/UiItem.js index 36fc687..da36678 100644 --- a/src/components/UiItemList/UiItem.js +++ b/src/components/UiItemList/UiItem.js @@ -122,7 +122,9 @@ export class Toggle extends UiControl { if (this.isEnabled()) { const control = this.props.item; 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); } }