Completely rework how icons work in mqtt control map

This commit is contained in:
uwap 2018-06-24 16:34:59 +02:00
parent 8a37cf2c95
commit ed0f22645e
14 changed files with 216 additions and 111 deletions

View file

@ -2,6 +2,7 @@
import type { Config } from "config/flowtypes";
import * as types from "config/types";
import { hex, rgb, rgba, rainbow } from "config/colors";
import { mdi, raw_mdi } from "config/icon";
import { esper_topics, esper_statistics, floalt } from "./utils";
const config : Config = {
@ -194,63 +195,64 @@ const config : Config = {
led_stahltrager: {
name: "LED Stahlträger",
position: [380, 590],
icon: "white-balance-iridescent",
icon: mdi("white-balance-iridescent"),
iconColor: ({led_stahltraeger}) => led_stahltraeger == "on" ? rainbow : hex("#000000"),
ui: [
{
type: "toggle",
text: "Stahlträger LED",
topic: "led_stahltraeger",
icon: "power"
icon: mdi("power")
},
]
},
snackbar: {
name: "Snackbar",
position: [510, 500],
icon: "fridge",
icon: mdi("fridge"),
iconColor: ({snackbar}) => snackbar == "on" ? hex("#E20074") : hex("#000000"),
ui: [
{
type: "toggle",
text: "Snackbar",
topic: "snackbar",
icon: "power"
icon: mdi("power")
}
]
},
twinkle: {
name: "Twinkle",
position: [530, 560],
icon: ({twinkle}) => twinkle == "on" ? "led-on flip-v" : "led-off flip-v",
icon: ({twinkle}) =>
twinkle == "on" ? raw_mdi("led-on flip-v") : raw_mdi("led-off flip-v"),
iconColor: ({twinkle}) => twinkle == "on" ? rainbow : hex("#000000"),
ui: [
{
type: "toggle",
text: "Twinkle",
topic: "twinkle",
icon: "power"
icon: mdi("power")
}
]
},
fan: {
name: "Ventilator",
position: [520, 450],
icon: "fan",
icon: mdi("fan"),
iconColor: ({fan}) => fan == "on" ? hex("#00FF00") : hex("#000000"),
ui: [
{
type: "toggle",
text: "Ventilator",
topic: "fan",
icon: "power"
icon: mdi("power")
}
]
},
cashdesk: {
name: "Cashdesk",
position: [500, 470],
icon: "coin",
icon: mdi("coin"),
ui: [
{
type: "link",
@ -262,49 +264,49 @@ const config : Config = {
videogames: {
name: "Videospiele",
position: [100, 100],
icon: "gamepad-variant",
icon: mdi("gamepad-variant"),
iconColor: ({videogames}) => videogames == "on" ? hex("#00FF00") : hex("#000000"),
ui: [
{
type: "toggle",
text: "Videospiele",
topic: "videogames",
icon: "power"
icon: mdi("power")
}
]
},
olymp_pc: {
name: "Rechner und Drucker",
position: [297, 90],
icon: "desktop-classic",
icon: mdi("desktop-classic"),
iconColor: ({olymp_pc}) => olymp_pc == "on" ? hex("#00FF00") : hex("#000000"),
ui: [
{
type: "toggle",
text: "Rechner und Drucker",
topic: "olymp_pc",
icon: "power"
icon: mdi("power")
}
]
},
flyfry: {
name: "Fliegenbratgerät",
position: [450, 590],
icon: "fire",
icon: mdi("fire"),
iconColor: ({flyfry}) => flyfry == "on" ? hex("#6666FF") : hex("#000000"),
ui: esper_statistics("flyfry", [
{
type: "toggle",
text: "Fliegenbratgerät",
topic: "flyfry",
icon: "power"
icon: mdi("power")
}
])
},
artnet: {
name: "Artnet",
position: [535,480],
icon: "spotlight",
icon: mdi("spotlight"),
iconColor: ({artnet}) =>
({
off: hex("#000000"),
@ -321,7 +323,7 @@ const config : Config = {
topic: "artnet",
on: "cycle",
toggled: val => val != "off",
icon: "power"
icon: mdi("power")
},
{
type: "dropDown",
@ -335,7 +337,7 @@ const config : Config = {
cycle: "Farbwechsel"
},
enableCondition: val => val != "off",
icon: "palette"
icon: mdi("palette")
}
]
},
@ -344,12 +346,12 @@ const config : Config = {
position: [350, 650],
iconColor: ({onkyo_connection, onkyo_power}) =>
onkyo_connection != "connected" ? hex("#888888") : (onkyo_power == "on" ? hex("#00FF00") : hex("#000000")),
icon: "audio-video",
icon: mdi("audio-video"),
ui: [
{
type: "toggle",
text: "Power",
icon: "power",
icon: mdi("power"),
topic: "onkyo_power",
enableCondition: (a, b, state) => state.onkyo_connection.internal == "connected"
},
@ -363,14 +365,14 @@ const config : Config = {
topic: "onkyo_volume",
min: 0,
max: 50,
icon: "volume-high",
icon: mdi("volume-high"),
enableCondition: (a, b, state) => state.onkyo_connection.internal == "connected"
},
{
type: "toggle",
text: "Mute",
topic: "onkyo_mute",
icon: "volume-off",
icon: mdi("volume-off"),
enableCondition: (a, b, state) => state.onkyo_connection.internal == "connected"
},
{
@ -388,7 +390,7 @@ const config : Config = {
pult: "Pult",
front: "Front HDMI"
},
icon: "usb",
icon: mdi("usb"),
enableCondition: (a, b, state) => state.onkyo_connection.internal == "connected"
},
{
@ -407,7 +409,7 @@ const config : Config = {
somafm_beatblender: "Beat Blender (Soma FM)",
ponyville: "Ponyville FM"
},
icon: "radio",
icon: mdi("radio"),
enableCondition: (a, b, state) => state.onkyo_connection.internal == "connected" && state.onkyo_inputs.internal == "netzwerk"
},
{
@ -424,28 +426,28 @@ const config : Config = {
rundumleuchte: {
name: "Rundumleuchte",
position: [310,275],
icon: "alarm-light",
icon: mdi("alarm-light"),
iconColor: ({rundumleuchte}) => rundumleuchte == "on" ? hex("#F0DF10") : hex("#000000"),
ui: [
{
type: "toggle",
text: "Rundumleuchte",
topic: "rundumleuchte",
icon: "power"
icon: mdi("power")
}
]
},
alarm: {
name: "Alarm",
position: [340, 250],
icon: "alarm-bell",
icon: mdi("alarm-bell"),
iconColor: () => hex("#000000"),
ui: esper_statistics("alarm")
},
door: {
name: "Tür",
position: [455,350],
icon: "swap-vertical",
icon: mdi("swap-vertical"),
iconColor: ({door_status}) => door_status == "on" ? hex("#00FF00") : hex("#FF0000"),
ui: [
{
@ -457,21 +459,21 @@ const config : Config = {
type: "text",
text: "Anwesend",
topic: "presence_status",
icon: "account"
icon: mdi("account")
}
]
},
infoscreen: {
name: "Infoscreen",
position: [255, 495],
icon: "television-guide flip-v",
icon: mdi("television-guide flip-v"),
iconColor: ({infoscreen}) => infoscreen == "on" ? hex("#4444FF") : hex("#000000"),
ui: [
{
type: "toggle",
text: "Infoscreen",
topic: "infoscreen",
icon: "power"
icon: mdi("power")
},
{
type: "link",
@ -483,7 +485,7 @@ const config : Config = {
printer_3d: {
name: "Ultimaker 3",
position: [754, 560],
icon: "printer-3d",
icon: mdi("printer-3d"),
iconColor: ({printer_3d_status}) =>
({
awaiting_interaction: hex("#b3b300"),
@ -504,7 +506,7 @@ const config : Config = {
},
{
type: "progress",
icon: "rotate-right",
icon: mdi("rotate-right"),
min: 0,
max: 1,
text: "Printing Progress",
@ -515,7 +517,7 @@ const config : Config = {
partkeepr: {
name: "Partkeepr",
position: [48, 450],
icon: "chip",
icon: mdi("chip"),
ui: [
{
type: "link",
@ -527,7 +529,7 @@ const config : Config = {
kitchen_light: {
name: "Deckenlicht Küche",
position: [325, 407],
icon: "ceiling-light",
icon: mdi("ceiling-light"),
ui: [
{
type: "toggle",
@ -536,14 +538,14 @@ const config : Config = {
toggled: n => parseInt(n) > 0,
topic: "kitchen_light_brightness",
text: "Ein/Ausschalten",
icon: "power"
icon: mdi("power")
},
{
type: "slider",
min: 0,
max: 100,
text: "Helligkeit",
icon: "brightness-7",
icon: mdi("brightness-7"),
topic: "kitchen_light_brightness",
delayedApply: true
},
@ -552,7 +554,7 @@ const config : Config = {
min: 0,
max: 100,
text: "Farbtemperatur",
icon: "weather-sunset-down",
icon: mdi("weather-sunset-down"),
topic: "kitchen_light_color",
delayedApply: true
},
@ -565,7 +567,7 @@ const config : Config = {
min: 0,
max: 100,
text: "Helligkeit",
icon: "brightness-7",
icon: mdi("brightness-7"),
topic: floalt.brightness("65537"),
delayedApply: true
},
@ -574,7 +576,7 @@ const config : Config = {
min: 0,
max: 100,
text: "Farbtemperatur",
icon: "weather-sunset-down",
icon: mdi("weather-sunset-down"),
topic: floalt.color("65537"),
delayedApply: true
},
@ -587,7 +589,7 @@ const config : Config = {
min: 0,
max: 100,
text: "Helligkeit",
icon: "brightness-7",
icon: mdi("brightness-7"),
topic: floalt.brightness("65538"),
delayedApply: true
},
@ -596,7 +598,7 @@ const config : Config = {
min: 0,
max: 100,
text: "Farbtemperatur",
icon: "weather-sunset-down",
icon: mdi("weather-sunset-down"),
topic: floalt.color("65538"),
delayedApply: true
},
@ -609,7 +611,7 @@ const config : Config = {
min: 0,
max: 100,
text: "Helligkeit",
icon: "brightness-7",
icon: mdi("brightness-7"),
topic: floalt.brightness("65539"),
delayedApply: true
},
@ -618,7 +620,7 @@ const config : Config = {
min: 0,
max: 100,
text: "Farbtemperatur",
icon: "weather-sunset-down",
icon: mdi("weather-sunset-down"),
topic: floalt.color("65539"),
delayedApply: true
},
@ -631,7 +633,7 @@ const config : Config = {
min: 0,
max: 100,
text: "Helligkeit",
icon: "brightness-7",
icon: mdi("brightness-7"),
topic: floalt.brightness("65540"),
delayedApply: true
},
@ -640,7 +642,7 @@ const config : Config = {
min: 0,
max: 100,
text: "Farbtemperatur",
icon: "weather-sunset-down",
icon: mdi("weather-sunset-down"),
topic: floalt.color("65540"),
delayedApply: true
}
@ -649,7 +651,7 @@ const config : Config = {
kitchen_sink_light: {
name: "Licht Spüle",
position: [300, 345],
icon: "wall-sconce-flat",
icon: mdi("wall-sconce-flat"),
ui: [
{
type: "toggle",
@ -658,14 +660,14 @@ const config : Config = {
toggled: n => parseInt(n) > 0,
topic: "kitchen_sink_light_brightness",
text: "Ein/Ausschalten",
icon: "power"
icon: mdi("power")
},
{
type: "slider",
min: 0,
max: 100,
text: "Helligkeit",
icon: "brightness-7",
icon: mdi("brightness-7"),
topic: "kitchen_sink_light_brightness",
delayedApply: true
}