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.
This commit is contained in:
Ranlvor 2020-10-17 16:48:07 +02:00
parent 65452ac0cb
commit 263507871b
Signed by untrusted user who does not match committer: Ranlvor
GPG key ID: 5E12D04750EF6F8E

View file

@ -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}`]: { [`${name}`]: {
state: { state: {
name: `home-rust/${topic}`, name: `home-rust/${topic}`,
@ -60,11 +61,12 @@ const topicHomeBoolean = (name: string, topic: string) => ({
name: `home-rust/${topic}/set`, name: `home-rust/${topic}/set`,
type: types.option({ on: "true", off: "false" }) 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}`]: { [`${name}`]: {
state: { state: {
name: `home-rust/${topic}`, name: `home-rust/${topic}`,
@ -74,7 +76,7 @@ const topicHomeNumber = (name: string, topic: string) => ({
name: `home-rust/${topic}/set`, name: `home-rust/${topic}/set`,
type: types.string type: types.string
}, },
defaultValue: 0 defaultValue: defaultValue
} }
}); });
@ -196,12 +198,12 @@ const config: Config = {
...topicTasmota("fanBedroom", "sonoff-bedroom-fan"), ...topicTasmota("fanBedroom", "sonoff-bedroom-fan"),
...topicHomeBoolean("fanBedroomAuto", "temperature-control/bedroom"), ...topicHomeBoolean("fanBedroomAuto", "temperature-control/bedroom"),
...topicHomeNumber("fanBedroomTarget", ...topicHomeNumber("fanBedroomTarget",
"temperature-control/bedroom/target"), "temperature-control/bedroom/target", 21.5),
...topicTasmota("fanOffice", "sonoff-office-fan"), ...topicTasmota("fanOffice", "sonoff-office-fan"),
...topicHomeBoolean("fanOfficeAuto", "temperature-control/office"), ...topicHomeBoolean("fanOfficeAuto", "temperature-control/office"),
...topicHomeBoolean("lueftenHint", "lueften"), ...topicHomeBoolean("lueftenHint", "lueften"),
...topicHomeNumber("fanOfficeTarget", ...topicHomeNumber("fanOfficeTarget",
"temperature-control/office/target"), "temperature-control/office/target", 21.5),
...topicBulbNumber("hallway", "brightness"), ...topicBulbNumber("hallway", "brightness"),
...topicBulbState("hallway"), ...topicBulbState("hallway"),
...topicBulbNumber("hallway2", "brightness"), ...topicBulbNumber("hallway2", "brightness"),
@ -211,7 +213,8 @@ const config: Config = {
...topicBulbState("office"), ...topicBulbState("office"),
...topicBulbNumber("office", "brightness"), ...topicBulbNumber("office", "brightness"),
...topicTasmota("speakerOffice", "sonoff-office-speaker"), ...topicTasmota("speakerOffice", "sonoff-office-speaker"),
...topicHomeBoolean("officeSwitchPollingActive", "switch/office/polling") ...topicHomeBoolean("officeSwitchPollingActive", "switch/office/polling",
true)
} }
], ],
controls: { controls: {