Add helper function for boolean topics
This commit is contained in:
parent
70240d9dd6
commit
a92c57c58d
1 changed files with 18 additions and 44 deletions
|
|
@ -18,6 +18,20 @@ const topicBulb = (bulb: string, argument: string) => ({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const topicHomeBoolean = (name: string, topic: string) => ({
|
||||||
|
[`${name}`]: {
|
||||||
|
state: {
|
||||||
|
name: `home-rust/${topic}`,
|
||||||
|
type: types.option({ true: "on", false: "off" })
|
||||||
|
},
|
||||||
|
command: {
|
||||||
|
name: `home-rust/${topic}/set`,
|
||||||
|
type: types.option({ on: "true", off: "false" })
|
||||||
|
},
|
||||||
|
defaultValue: "OFF"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const topicTasmota = (name: string, topic: string) => ({
|
const topicTasmota = (name: string, topic: string) => ({
|
||||||
[`${name}State`]: {
|
[`${name}State`]: {
|
||||||
state: {
|
state: {
|
||||||
|
|
@ -117,28 +131,8 @@ const config: Config = {
|
||||||
},
|
},
|
||||||
defaultValue: "OFF"
|
defaultValue: "OFF"
|
||||||
},
|
},
|
||||||
livingroomKodiControlled: {
|
...topicHomeBoolean("livingroomKodiControlled", "bulb/livingroom/kodi-controlled"),
|
||||||
state: {
|
...topicHomeBoolean("bedroomWakeup", "wakeup"),
|
||||||
name: "home-rust/bulb/livingroom/kodi-controlled",
|
|
||||||
type: types.option({ true: "on", false: "off" })
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "home-rust/bulb/livingroom/kodi-controlled/set",
|
|
||||||
type: types.option({ on: "true", off: "false" })
|
|
||||||
},
|
|
||||||
defaultValue: "OFF"
|
|
||||||
},
|
|
||||||
bedroomWakeup: {
|
|
||||||
state: {
|
|
||||||
name: "home-rust/wakeup",
|
|
||||||
type: types.option({ true: "on", false: "off" })
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "home-rust/wakeup/set",
|
|
||||||
type: types.option({ on: "true", off: "false" })
|
|
||||||
},
|
|
||||||
defaultValue: "OFF"
|
|
||||||
},
|
|
||||||
bedroomBrightness: {
|
bedroomBrightness: {
|
||||||
state: {
|
state: {
|
||||||
name: "home-rust/bulb/bedroom/brightness",
|
name: "home-rust/bulb/bedroom/brightness",
|
||||||
|
|
@ -176,29 +170,9 @@ const config: Config = {
|
||||||
defaultValue: "OFF"
|
defaultValue: "OFF"
|
||||||
},
|
},
|
||||||
...topicTasmota("fanBedroom", "sonoff-bedroom-fan"),
|
...topicTasmota("fanBedroom", "sonoff-bedroom-fan"),
|
||||||
fanBedroomAuto: {
|
...topicHomeBoolean("fanBedroomAuto", "temperature-control/bedroom"),
|
||||||
state: {
|
|
||||||
name: "home-rust/temperature-control/bedroom",
|
|
||||||
type: types.option({ true: "on", false: "off" })
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "home-rust/temperature-control/bedroom/set",
|
|
||||||
type: types.option({ on: "true", off: "false" })
|
|
||||||
},
|
|
||||||
defaultValue: "OFF"
|
|
||||||
},
|
|
||||||
...topicTasmota("fanOffice", "sonoff-office-fan"),
|
...topicTasmota("fanOffice", "sonoff-office-fan"),
|
||||||
fanOfficeAuto: {
|
...topicHomeBoolean("fanOfficeAuto", "temperature-control/office"),
|
||||||
state: {
|
|
||||||
name: "home-rust/temperature-control/office",
|
|
||||||
type: types.option({ true: "on", false: "off" })
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "home-rust/temperature-control/office/set",
|
|
||||||
type: types.option({ on: "true", off: "false" })
|
|
||||||
},
|
|
||||||
defaultValue: "OFF"
|
|
||||||
},
|
|
||||||
hallwayBrightness: {
|
hallwayBrightness: {
|
||||||
state: {
|
state: {
|
||||||
name: "home-rust/bulb/hallway/brightness",
|
name: "home-rust/bulb/hallway/brightness",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue