From 263507871bcaa384c1f8c84b5c37404e7b9c1e56 Mon Sep 17 00:00:00 2001 From: Ranlvor Date: Sat, 17 Oct 2020 16:48:07 +0200 Subject: [PATCH] Change some default values to home-rust compile-time-defaults Because after losing MQTT-Broker-State and restarting home-rust it reverts to compile-time-defaults but does not write this defaults back to the MQTT-Broker. So the map should just assume that any parameter not received via MQTT should be set to the compile-time-values. --- config/uwap-home/index.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/config/uwap-home/index.js b/config/uwap-home/index.js index 3012c40..cb5294e 100644 --- a/config/uwap-home/index.js +++ b/config/uwap-home/index.js @@ -50,7 +50,8 @@ const topicBulbNumber = (bulb: string, parameter: string) => ({ } }); -const topicHomeBoolean = (name: string, topic: string) => ({ +const topicHomeBoolean = (name: string, topic: string, + defaultValue: boolean = false) => ({ [`${name}`]: { state: { name: `home-rust/${topic}`, @@ -60,11 +61,12 @@ const topicHomeBoolean = (name: string, topic: string) => ({ name: `home-rust/${topic}/set`, type: types.option({ on: "true", off: "false" }) }, - defaultValue: "OFF" + defaultValue: defaultValue ? "on" : "off" } }); -const topicHomeNumber = (name: string, topic: string) => ({ +const topicHomeNumber = (name: string, topic: string, + defaultValue: number = 0) => ({ [`${name}`]: { state: { name: `home-rust/${topic}`, @@ -74,7 +76,7 @@ const topicHomeNumber = (name: string, topic: string) => ({ name: `home-rust/${topic}/set`, type: types.string }, - defaultValue: 0 + defaultValue: defaultValue } }); @@ -196,12 +198,12 @@ const config: Config = { ...topicTasmota("fanBedroom", "sonoff-bedroom-fan"), ...topicHomeBoolean("fanBedroomAuto", "temperature-control/bedroom"), ...topicHomeNumber("fanBedroomTarget", - "temperature-control/bedroom/target"), + "temperature-control/bedroom/target", 21.5), ...topicTasmota("fanOffice", "sonoff-office-fan"), ...topicHomeBoolean("fanOfficeAuto", "temperature-control/office"), ...topicHomeBoolean("lueftenHint", "lueften"), ...topicHomeNumber("fanOfficeTarget", - "temperature-control/office/target"), + "temperature-control/office/target", 21.5), ...topicBulbNumber("hallway", "brightness"), ...topicBulbState("hallway"), ...topicBulbNumber("hallway2", "brightness"), @@ -211,7 +213,8 @@ const config: Config = { ...topicBulbState("office"), ...topicBulbNumber("office", "brightness"), ...topicTasmota("speakerOffice", "sonoff-office-speaker"), - ...topicHomeBoolean("officeSwitchPollingActive", "switch/office/polling") + ...topicHomeBoolean("officeSwitchPollingActive", "switch/office/polling", + true) } ], controls: {