Simplify config a bit and show online-state of tasmota-devices (#68)
* RZL: Simplify config a bit by using template for tasmota topics * RZL: show online-state of tasmota-devices in icon color
This commit is contained in:
parent
c7202a9141
commit
8484784c47
2 changed files with 43 additions and 37 deletions
|
|
@ -3,7 +3,7 @@ import type { Config } from "config/flowtypes";
|
||||||
import * as types from "config/types";
|
import * as types from "config/types";
|
||||||
import { hex, rgb, rgba, rainbow } from "config/colors";
|
import { hex, rgb, rgba, rainbow } from "config/colors";
|
||||||
import { mdi, rawMdi, mdiBattery } from "config/icon";
|
import { mdi, rawMdi, mdiBattery } from "config/icon";
|
||||||
import { esper_topics, esper_statistics, floalt, tradfri_remote } from "./utils";
|
import { esper_topics, esper_statistics, floalt, tradfri_remote, tasmota } from "./utils";
|
||||||
|
|
||||||
import * as onkyo from "./onkyo";
|
import * as onkyo from "./onkyo";
|
||||||
|
|
||||||
|
|
@ -26,17 +26,6 @@ const config: Config = {
|
||||||
},
|
},
|
||||||
defaultValue: "off"
|
defaultValue: "off"
|
||||||
},
|
},
|
||||||
snackbar: {
|
|
||||||
state: {
|
|
||||||
name: "stat/sonoff6/POWER",
|
|
||||||
type: types.option({ ON: "on", OFF: "off" })
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "cmnd/sonoff6/power",
|
|
||||||
type: types.option({ on: "ON", off: "OFF" })
|
|
||||||
},
|
|
||||||
defaultValue: "off"
|
|
||||||
},
|
|
||||||
twinkle: {
|
twinkle: {
|
||||||
state: {
|
state: {
|
||||||
name: "/service/openhab/out/pca301_twinkle/state",
|
name: "/service/openhab/out/pca301_twinkle/state",
|
||||||
|
|
@ -81,17 +70,6 @@ const config: Config = {
|
||||||
},
|
},
|
||||||
defaultValue: "off"
|
defaultValue: "off"
|
||||||
},
|
},
|
||||||
olymp_printer: {
|
|
||||||
state: {
|
|
||||||
name: "stat/sonoff2/POWER",
|
|
||||||
type: types.option({ ON: "on", OFF: "off" })
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "cmnd/sonoff2/power",
|
|
||||||
type: types.option({ on: "ON", off: "OFF" })
|
|
||||||
},
|
|
||||||
defaultValue: "off"
|
|
||||||
},
|
|
||||||
flyfry: {
|
flyfry: {
|
||||||
state: {
|
state: {
|
||||||
name: "/service/openhab/out/wifi_flyfry/state",
|
name: "/service/openhab/out/wifi_flyfry/state",
|
||||||
|
|
@ -149,17 +127,6 @@ const config: Config = {
|
||||||
},
|
},
|
||||||
defaultValue: ""
|
defaultValue: ""
|
||||||
},
|
},
|
||||||
infoscreen: {
|
|
||||||
state: {
|
|
||||||
name: "stat/sonoff7/POWER",
|
|
||||||
type: types.option({ ON: "on", OFF: "off" })
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "cmnd/sonoff7/power",
|
|
||||||
type: types.option({ on: "ON", off: "OFF" })
|
|
||||||
},
|
|
||||||
defaultValue: "off"
|
|
||||||
},
|
|
||||||
projector: {
|
projector: {
|
||||||
state: {
|
state: {
|
||||||
name: "/service/beamer/state",
|
name: "/service/beamer/state",
|
||||||
|
|
@ -243,6 +210,11 @@ const config: Config = {
|
||||||
defaultValue: "0"
|
defaultValue: "0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//Tasmota-Dosen
|
||||||
|
tasmota.topics("2", "olymp_printer"),
|
||||||
|
tasmota.topics("6", "snackbar"),
|
||||||
|
tasmota.topics("7", "infoscreen"),
|
||||||
|
|
||||||
//Kuechen-Floalts
|
//Kuechen-Floalts
|
||||||
floalt.topics("65537"),
|
floalt.topics("65537"),
|
||||||
floalt.topics("65538"),
|
floalt.topics("65538"),
|
||||||
|
|
@ -282,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",
|
||||||
|
|
@ -366,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",
|
||||||
|
|
@ -498,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",
|
||||||
|
|
|
||||||
|
|
@ -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) => ({
|
||||||
|
|
@ -42,6 +43,39 @@ export const esper_topics = (chip_id: string, name: string) => ({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const tasmota = {
|
||||||
|
topics: (id: string, name: string) => ({
|
||||||
|
[name]: {
|
||||||
|
state: {
|
||||||
|
name: `stat/sonoff${id}/POWER`,
|
||||||
|
type: types.option({ ON: "on", OFF: "off" })
|
||||||
|
},
|
||||||
|
command: {
|
||||||
|
name: `cmnd/sonoff${id}/power`,
|
||||||
|
type: types.option({ on: "ON", off: "OFF" })
|
||||||
|
},
|
||||||
|
defaultValue: "off"
|
||||||
|
},
|
||||||
|
[`${name}_online`]: {
|
||||||
|
state: {
|
||||||
|
name: `tele/sonoff${id}/LWT`,
|
||||||
|
type: types.string
|
||||||
|
},
|
||||||
|
defaultValue: "offline"
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
icon_color: (name: string, on_color: Color = hex("#00FF00")) => (state: State) => {
|
||||||
|
if (state[`${name}_online`] === "offline") {
|
||||||
|
return hex("#888888");
|
||||||
|
} else {
|
||||||
|
if (state[name] === "on") {
|
||||||
|
return on_color;
|
||||||
|
} else {
|
||||||
|
return hex("#000000");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
export const floalt = {
|
export const floalt = {
|
||||||
color: (light_id: string) => `floalt_${light_id}_color`,
|
color: (light_id: string) => `floalt_${light_id}_color`,
|
||||||
brightness: (light_id: string) => `floalt_${light_id}_brightness`,
|
brightness: (light_id: string) => `floalt_${light_id}_brightness`,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue