use types.option instead of types.string for online/offline on tasmota

This commit is contained in:
Ranlvor 2018-09-02 02:54:52 +02:00
parent f1ffe78a40
commit ba10e8945c
Signed by untrusted user who does not match committer: Ranlvor
GPG key ID: 5E12D04750EF6F8E
2 changed files with 8 additions and 8 deletions

View file

@ -62,9 +62,9 @@ const config: Config = {
snackbar_led_online: { snackbar_led_online: {
state: { state: {
name: "tele/tasmota-snackbar/LWT", name: "tele/tasmota-snackbar/LWT",
type: types.string type: types.option({ Online: "on", online: "on", Offline: "off", offline: "off" })
}, },
defaultValue: "Offline" defaultValue: "off"
}, },
twinkle: { twinkle: {
state: { state: {
@ -348,7 +348,7 @@ const config: Config = {
"12": "Fire Pattern" "12": "Fire Pattern"
}, },
icon: mdi("settings"), icon: mdi("settings"),
enableCondition: ({ snackbar_led_online }) => snackbar_led_online != "Offline" enableCondition: ({ snackbar_led_online }) => snackbar_led_online == "on"
}, },
{ {
type: "slider", type: "slider",
@ -357,7 +357,7 @@ const config: Config = {
min: 0, min: 0,
max: 100, max: 100,
icon: mdi("brightness-7"), icon: mdi("brightness-7"),
enableCondition: ({ snackbar_led_online }) => snackbar_led_online != "Offline" enableCondition: ({ snackbar_led_online }) => snackbar_led_online == "on"
}, },
{ {
type: "slider", type: "slider",
@ -366,7 +366,7 @@ const config: Config = {
min: 0, min: 0,
max: 20, max: 20,
icon: mdi("speedometer"), icon: mdi("speedometer"),
enableCondition: ({ snackbar_led_online }) => snackbar_led_online != "Offline" enableCondition: ({ snackbar_led_online }) => snackbar_led_online == "on"
}, },
] ]
}, },

View file

@ -59,13 +59,13 @@ export const tasmota = {
[`${name}_online`]: { [`${name}_online`]: {
state: { state: {
name: `tele/sonoff${id}/LWT`, name: `tele/sonoff${id}/LWT`,
type: types.string type: types.option({ Online: "on", online: "on", Offline: "off", offline: "off" })
}, },
defaultValue: "offline" defaultValue: "off"
}, },
}), }),
icon_color: (name: string, on_color: Color = hex("#00FF00")) => (state: State) => { icon_color: (name: string, on_color: Color = hex("#00FF00")) => (state: State) => {
if (state[`${name}_online`] === "offline") { if (state[`${name}_online`] === "off") {
return hex("#888888"); return hex("#888888");
} else { } else {
if (state[name] === "on") { if (state[name] === "on") {