RZL: show online-state of tasmota-devices in icon color

This commit is contained in:
Ranlvor 2018-08-04 16:27:26 +02:00
parent 032056b2e3
commit 2728e082bd
Signed by untrusted user who does not match committer: Ranlvor
GPG key ID: 5E12D04750EF6F8E
2 changed files with 14 additions and 5 deletions

View file

@ -254,7 +254,7 @@ const config: Config = {
name: "Snackbar", name: "Snackbar",
position: [510, 500], position: [510, 500],
icon: mdi("fridge"), icon: mdi("fridge"),
iconColor: ({snackbar}) => snackbar == "on" ? hex("#E20074") : hex("#000000"), iconColor: tasmota.icon_color("snackbar", hex("#E20074")),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
@ -338,7 +338,7 @@ const config: Config = {
name: "Drucker", name: "Drucker",
position: [335, 90], position: [335, 90],
icon: mdi("printer"), icon: mdi("printer"),
iconColor: ({olymp_printer}) => olymp_printer == "on" ? hex("#00FF00") : hex("#000000"), iconColor: tasmota.icon_color("olymp_printer"),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
@ -470,7 +470,7 @@ const config: Config = {
name: "Infoscreen", name: "Infoscreen",
position: [255, 495], position: [255, 495],
icon: mdi("television-guide flip-v"), icon: mdi("television-guide flip-v"),
iconColor: ({infoscreen}) => infoscreen == "on" ? hex("#4444FF") : hex("#000000"), iconColor: tasmota.icon_color("infoscreen", hex("#4444FF")),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",

View file

@ -1,6 +1,7 @@
// @flow // @flow
import type { ControlUI } from "config/flowtypes"; import type { ControlUI } from "config/flowtypes";
import { mdi } from "config/icon"; import { mdi } from "config/icon";
import { hex } from "config/colors";
import * as types from "config/types"; import * as types from "config/types";
export const esper_topics = (chip_id: string, name: string) => ({ export const esper_topics = (chip_id: string, name: string) => ({
@ -54,8 +55,16 @@ export const tasmota = {
type: types.option({ on: "ON", off: "OFF" }) type: types.option({ on: "ON", off: "OFF" })
}, },
defaultValue: "off" defaultValue: "off"
} },
}) [`${name}_online`]: {
state: {
name: `tele/sonoff${id}/LWT`,
type: types.option({ online: "online", offline: "offline" })
},
defaultValue: "offline"
},
}),
icon_color: (name: string, on_color: Color = hex("#00FF00")) => (state) => state[`${name}_online`] == "offline" ? hex("#888888") : (state[name] == "on" ? on_color : hex("#000000"))
} }
export const floalt = { export const floalt = {
color: (light_id: string) => `floalt_${light_id}_color`, color: (light_id: string) => `floalt_${light_id}_color`,