From 8e002e3b1a9d6743c8a6987d3ac73ff00d87e11e Mon Sep 17 00:00:00 2001 From: Ranlvor Date: Tue, 15 Nov 2022 17:56:52 +0100 Subject: [PATCH] add button for wled office auto on/off --- config/uwap-home/index.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/config/uwap-home/index.js b/config/uwap-home/index.js index 9ced8e7..4a283a0 100644 --- a/config/uwap-home/index.js +++ b/config/uwap-home/index.js @@ -56,14 +56,17 @@ const topicBulbNumber = (bulb: string, parameter: string) => topicZigbeeNumber(b const topicGroupNumber = (bulb: string, parameter: string) => topicZigbeeNumber(bulb, `group_${bulb}`, parameter); const topicHomeBoolean = (name: string, topic: string, + defaultValue: boolean = false) => topicBoolean(name, `home-rust/${topic}`, defaultValue); + +const topicBoolean = (name: string, topic: string, defaultValue: boolean = false) => ({ [`${name}`]: { state: { - name: `home-rust/${topic}`, + name: `${topic}`, type: types.option({ true: "on", false: "off" }) }, command: { - name: `home-rust/${topic}/set`, + name: `${topic}/set`, type: types.option({ on: "true", off: "false" }) }, defaultValue: defaultValue ? "on" : "off" @@ -325,6 +328,8 @@ const config: Config = { ...topicHomeBoolean("officeSwitchPollingActive", "switch/office/polling", true), + ...topicBoolean("wledOfficeAuto", "wled/office/automatic"), + ...topicTasmota("fanBedroom", "sonoff-bedroom-fan"), ...topicTasmota("fanOffice", "sonoff-office-fan"), ...topicTasmota("tasmotaProjector", "tasmota-projector"), @@ -671,8 +676,8 @@ const config: Config = { name: "Jalousien Büro", position: [170,658], icon: withState((s) => ( - (s["officeBlindLeftposition"] <= 9 && - s["officeBlindRightposition"] <= 9) ? + (parseInt(s["officeBlindLeftposition"]) <= 9 && + parseInt(s["officeBlindRightposition"]) <= 9) ? svg(icons.mdiBlindsOpen) : svg(icons.mdiBlinds) )), @@ -920,6 +925,12 @@ const config: Config = { off: "0", toggled: (n) => parseInt(n, 10) > 0 }, + { + type: "toggle", + topic: "wledOfficeAuto", + text: "Automatik", + icon: svg(icons.mdiAutoDownload) + }, { type: "slider", min: 1,