Add template for tasmota state topics

This commit is contained in:
Ranlvor 2019-05-24 18:33:35 +02:00
parent da7161c0dd
commit 70240d9dd6
Signed by untrusted user who does not match committer: Ranlvor
GPG key ID: 5E12D04750EF6F8E

View file

@ -18,6 +18,23 @@ const topicBulb = (bulb: string, argument: string) => ({
} }
}); });
const topicTasmota = (name: string, topic: string) => ({
[`${name}State`]: {
state: {
name: `stat/${topic}/POWER`,
type: types.option({
OFF: "off",
ON: "on"
})
},
command: {
name: `cmnd/${topic}/POWER`,
type: types.string
},
defaultValue: "OFF"
}
});
const sliderRGB = (bulb: string, argument: string) => ( const sliderRGB = (bulb: string, argument: string) => (
[{ [{
type: "slider", type: "slider",
@ -158,20 +175,7 @@ const config: Config = {
}, },
defaultValue: "OFF" defaultValue: "OFF"
}, },
fanBedroomState: { ...topicTasmota("fanBedroom", "sonoff-bedroom-fan"),
state: {
name: "stat/sonoff-bedroom-fan/POWER",
type: types.option({
OFF: "off",
ON: "on"
})
},
command: {
name: "cmnd/sonoff-bedroom-fan/POWER",
type: types.string
},
defaultValue: "OFF"
},
fanBedroomAuto: { fanBedroomAuto: {
state: { state: {
name: "home-rust/temperature-control/bedroom", name: "home-rust/temperature-control/bedroom",
@ -183,20 +187,7 @@ const config: Config = {
}, },
defaultValue: "OFF" defaultValue: "OFF"
}, },
fanOfficeState: { ...topicTasmota("fanOffice", "sonoff-office-fan"),
state: {
name: "stat/sonoff-office-fan/POWER",
type: types.option({
OFF: "off",
ON: "on"
})
},
command: {
name: "cmnd/sonoff-office-fan/POWER",
type: types.string
},
defaultValue: "OFF"
},
fanOfficeAuto: { fanOfficeAuto: {
state: { state: {
name: "home-rust/temperature-control/office", name: "home-rust/temperature-control/office",