uwap-home: Add second hallway light (#135)
* uwap-home: Add second hallway light * show bulb on/off state on map icon * Add icon for nas * Use new zigbee2mqtt state-topics The new state-topics-feature of zigbee2mqtt makes the translation-layer in home-rust obsolete for simple (non color-changing) bulbs. * uwap-home: Show tucana, Show Lüften Erinnerung * Refactor topics: more template-functions, less spaghetti code * uwap-home: Add office switch * tucana: Support displaying half duplex, too * Increase target temperature slider range After a hot summer it can be usefull to be able to set the slider to e.G. 25°C
This commit is contained in:
parent
d39e547623
commit
66ff91da2d
1 changed files with 193 additions and 126 deletions
|
|
@ -4,7 +4,7 @@ import * as types from "config/types";
|
||||||
import { mdi, rawMdi } from "config/icon";
|
import { mdi, rawMdi } from "config/icon";
|
||||||
import { hex } from "config/colors";
|
import { hex } from "config/colors";
|
||||||
|
|
||||||
const topicBulb = (bulb: string, argument: string) => ({
|
const topicBulbHomeRust = (bulb: string, argument: string) => ({
|
||||||
[`${bulb}${argument}`]: {
|
[`${bulb}${argument}`]: {
|
||||||
state: {
|
state: {
|
||||||
name: `home-rust/bulb/${bulb}/${argument}`,
|
name: `home-rust/bulb/${bulb}/${argument}`,
|
||||||
|
|
@ -18,6 +18,37 @@ const topicBulb = (bulb: string, argument: string) => ({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const topicBulbState = (bulb: string) => ({
|
||||||
|
[`${bulb}State`]: {
|
||||||
|
state: {
|
||||||
|
name: `zigbee2mqtt/bulb_${bulb}/state`,
|
||||||
|
type: types.option({
|
||||||
|
OFF: "off",
|
||||||
|
ON: "on"
|
||||||
|
})
|
||||||
|
},
|
||||||
|
command: {
|
||||||
|
name: `zigbee2mqtt/bulb_${bulb}/set/state`,
|
||||||
|
type: types.string
|
||||||
|
},
|
||||||
|
defaultValue: "OFF"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const topicBulbNumber = (bulb: string, parameter: string) => ({
|
||||||
|
[`${bulb}${parameter}`]: {
|
||||||
|
state: {
|
||||||
|
name: `zigbee2mqtt/bulb_${bulb}/${parameter}`,
|
||||||
|
type: types.string
|
||||||
|
},
|
||||||
|
command: {
|
||||||
|
name: `zigbee2mqtt/bulb_${bulb}/set/${parameter}`,
|
||||||
|
type: types.string
|
||||||
|
},
|
||||||
|
defaultValue: "0"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const topicHomeBoolean = (name: string, topic: string) => ({
|
const topicHomeBoolean = (name: string, topic: string) => ({
|
||||||
[`${name}`]: {
|
[`${name}`]: {
|
||||||
state: {
|
state: {
|
||||||
|
|
@ -103,146 +134,71 @@ const config: Config = {
|
||||||
},
|
},
|
||||||
topics: [
|
topics: [
|
||||||
{
|
{
|
||||||
|
...topicBulbHomeRust("livingroom", "r"),
|
||||||
/*
|
...topicBulbHomeRust("livingroom", "g"),
|
||||||
*zigbee2mqtt/bulb_livingroom
|
...topicBulbHomeRust("livingroom", "b"),
|
||||||
*zigbee2mqtt/bulb_hallway
|
...topicBulbHomeRust("livingroom", "h"),
|
||||||
*zigbee2mqtt/bulb_bedroom
|
...topicBulbHomeRust("livingroom", "s"),
|
||||||
*/
|
...topicBulbHomeRust("livingroom", "v"),
|
||||||
|
...topicBulbHomeRust("livingroom", "x"),
|
||||||
...topicBulb("livingroom", "r"),
|
...topicBulbHomeRust("livingroom", "y"),
|
||||||
...topicBulb("livingroom", "g"),
|
...topicBulbHomeRust("livingroom", "animation-speed"),
|
||||||
...topicBulb("livingroom", "b"),
|
...topicBulbHomeRust("livingroom", "mode"),
|
||||||
...topicBulb("livingroom", "h"),
|
...topicBulbNumber("livingroom", "brightness"),
|
||||||
...topicBulb("livingroom", "s"),
|
...topicBulbState("livingroom"),
|
||||||
...topicBulb("livingroom", "v"),
|
nasPower: {
|
||||||
...topicBulb("livingroom", "x"),
|
|
||||||
...topicBulb("livingroom", "y"),
|
|
||||||
...topicBulb("livingroom", "animation-speed"),
|
|
||||||
...topicBulb("livingroom", "mode"),
|
|
||||||
livingroomBrightness: {
|
|
||||||
state: {
|
state: {
|
||||||
name: "home-rust/bulb/livingroom/brightness",
|
name: "nas/online",
|
||||||
type: types.string
|
type: types.string
|
||||||
},
|
},
|
||||||
command: {
|
command: {
|
||||||
name: "zigbee2mqtt/bulb_livingroom/set",
|
name: "home-rust/wake/nas",
|
||||||
type: (value) => JSON.stringify({ brightness: value.toString() })
|
type: types.string
|
||||||
},
|
},
|
||||||
defaultValue: "0"
|
defaultValue: "OFF"
|
||||||
},
|
},
|
||||||
livingroomState: {
|
tucanaPower: {
|
||||||
state: {
|
state: {
|
||||||
name: "home-rust/bulb/livingroom/state",
|
name: "home-rust/switch/office/8",
|
||||||
type: types.option({
|
type: types.option({
|
||||||
OFF: "off",
|
"0": "Link Down",
|
||||||
ON: "on"
|
"6": "1000M",
|
||||||
|
"5": "100M",
|
||||||
|
"4": "100M (Half Duplex)",
|
||||||
|
"3": "10M",
|
||||||
|
"2": "10M (Half Duplex)"
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
command: {
|
command: {
|
||||||
name: "zigbee2mqtt/bulb_livingroom/set",
|
name: "home-rust/wake/tucana",
|
||||||
type: (value) => JSON.stringify({ state: value.toString() })
|
type: types.string
|
||||||
},
|
},
|
||||||
defaultValue: "OFF"
|
defaultValue: "0"
|
||||||
},
|
},
|
||||||
...topicHomeBoolean("livingroomKodiControlled",
|
...topicHomeBoolean("livingroomKodiControlled",
|
||||||
"bulb/livingroom/kodi-controlled"),
|
"bulb/livingroom/kodi-controlled"),
|
||||||
...topicHomeBoolean("bedroomWakeup", "wakeup"),
|
...topicHomeBoolean("bedroomWakeup", "wakeup"),
|
||||||
bedroomBrightness: {
|
...topicBulbNumber("bedroom", "brightness"),
|
||||||
state: {
|
...topicBulbNumber("bedroom", "color_temp"),
|
||||||
name: "home-rust/bulb/bedroom/brightness",
|
...topicBulbNumber("hallway", "brightness"),
|
||||||
type: types.string
|
...topicBulbState("bedroom"),
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "zigbee2mqtt/bulb_bedroom/set",
|
|
||||||
type: (value) => JSON.stringify({ brightness: value.toString() })
|
|
||||||
},
|
|
||||||
defaultValue: "0"
|
|
||||||
},
|
|
||||||
bedroomColorTemp: {
|
|
||||||
state: {
|
|
||||||
name: "home-rust/bulb/bedroom/color_temp",
|
|
||||||
type: types.string
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "zigbee2mqtt/bulb_bedroom/set",
|
|
||||||
type: (value) => JSON.stringify({ "color_temp": value.toString() })
|
|
||||||
},
|
|
||||||
defaultValue: "0"
|
|
||||||
},
|
|
||||||
bedroomState: {
|
|
||||||
state: {
|
|
||||||
name: "home-rust/bulb/bedroom/state",
|
|
||||||
type: types.option({
|
|
||||||
OFF: "off",
|
|
||||||
ON: "on"
|
|
||||||
})
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "zigbee2mqtt/bulb_bedroom/set",
|
|
||||||
type: (value) => JSON.stringify({ state: value.toString() })
|
|
||||||
},
|
|
||||||
defaultValue: "OFF"
|
|
||||||
},
|
|
||||||
...topicTasmota("fanBedroom", "sonoff-bedroom-fan"),
|
...topicTasmota("fanBedroom", "sonoff-bedroom-fan"),
|
||||||
...topicHomeBoolean("fanBedroomAuto", "temperature-control/bedroom"),
|
...topicHomeBoolean("fanBedroomAuto", "temperature-control/bedroom"),
|
||||||
...topicHomeNumber("fanBedroomTarget",
|
...topicHomeNumber("fanBedroomTarget",
|
||||||
"temperature-control/bedroom/target"),
|
"temperature-control/bedroom/target"),
|
||||||
...topicTasmota("fanOffice", "sonoff-office-fan"),
|
...topicTasmota("fanOffice", "sonoff-office-fan"),
|
||||||
...topicHomeBoolean("fanOfficeAuto", "temperature-control/office"),
|
...topicHomeBoolean("fanOfficeAuto", "temperature-control/office"),
|
||||||
|
...topicHomeBoolean("lueftenHint", "lueften"),
|
||||||
...topicHomeNumber("fanOfficeTarget",
|
...topicHomeNumber("fanOfficeTarget",
|
||||||
"temperature-control/office/target"),
|
"temperature-control/office/target"),
|
||||||
hallwayBrightness: {
|
...topicBulbNumber("hallway", "brightness"),
|
||||||
state: {
|
...topicBulbState("hallway"),
|
||||||
name: "home-rust/bulb/hallway/brightness",
|
...topicBulbNumber("hallway2", "brightness"),
|
||||||
type: types.string
|
...topicBulbState("hallway2"),
|
||||||
},
|
...topicBulbState("office"),
|
||||||
command: {
|
...topicBulbNumber("office", "brightness"),
|
||||||
name: "zigbee2mqtt/bulb_hallway/set",
|
...topicTasmota("speakerOffice", "sonoff-office-speaker"),
|
||||||
type: (value) => JSON.stringify({ brightness: value.toString() })
|
...topicHomeBoolean("officeSwitchPollingActive", "switch/office/polling")
|
||||||
},
|
|
||||||
defaultValue: "0"
|
|
||||||
},
|
|
||||||
hallwayState: {
|
|
||||||
state: {
|
|
||||||
name: "home-rust/bulb/hallway/state",
|
|
||||||
type: types.option({
|
|
||||||
OFF: "off",
|
|
||||||
ON: "on"
|
|
||||||
})
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "zigbee2mqtt/bulb_hallway/set",
|
|
||||||
type: (value) => JSON.stringify({ state: value.toString() })
|
|
||||||
},
|
|
||||||
defaultValue: "OFF"
|
|
||||||
},
|
|
||||||
officeBrightness: {
|
|
||||||
state: {
|
|
||||||
name: "home-rust/bulb/office/brightness",
|
|
||||||
type: types.string
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "zigbee2mqtt/bulb_office/set",
|
|
||||||
type: (value) => JSON.stringify({ brightness: value.toString() })
|
|
||||||
},
|
|
||||||
defaultValue: "0"
|
|
||||||
},
|
|
||||||
officeState: {
|
|
||||||
state: {
|
|
||||||
name: "home-rust/bulb/office/state",
|
|
||||||
type: types.option({
|
|
||||||
OFF: "off",
|
|
||||||
ON: "on"
|
|
||||||
})
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
name: "zigbee2mqtt/bulb_office/set",
|
|
||||||
type: (value) => JSON.stringify({ state: value.toString() })
|
|
||||||
},
|
|
||||||
defaultValue: "OFF"
|
|
||||||
},
|
|
||||||
...topicTasmota("speakerOffice", "sonoff-office-speaker")
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
controls: {
|
controls: {
|
||||||
|
|
@ -250,6 +206,8 @@ const config: Config = {
|
||||||
name: "Schlafzimmer",
|
name: "Schlafzimmer",
|
||||||
position: [180, 130],
|
position: [180, 130],
|
||||||
icon: mdi("ceiling-light"),
|
icon: mdi("ceiling-light"),
|
||||||
|
iconColor: ({bedroomState}) =>
|
||||||
|
(bedroomState === "on" ? hex("#00FF00") : hex("#000000")),
|
||||||
ui: [
|
ui: [
|
||||||
{
|
{
|
||||||
type: "toggle",
|
type: "toggle",
|
||||||
|
|
@ -263,7 +221,7 @@ const config: Config = {
|
||||||
max: 255,
|
max: 255,
|
||||||
text: "Helligkeit",
|
text: "Helligkeit",
|
||||||
icon: mdi("brightness-7"),
|
icon: mdi("brightness-7"),
|
||||||
topic: "bedroomBrightness"
|
topic: "bedroombrightness"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "toggle",
|
type: "toggle",
|
||||||
|
|
@ -277,7 +235,7 @@ const config: Config = {
|
||||||
max: 454,
|
max: 454,
|
||||||
text: "Farbtemperatur",
|
text: "Farbtemperatur",
|
||||||
icon: mdi("weather-sunset-down"),
|
icon: mdi("weather-sunset-down"),
|
||||||
topic: "bedroomColorTemp"
|
topic: "bedroomcolor_temp"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -308,8 +266,8 @@ const config: Config = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "slider",
|
type: "slider",
|
||||||
min: 10,
|
min: 15,
|
||||||
max: 21.5,
|
max: 25,
|
||||||
step: 0.1,
|
step: 0.1,
|
||||||
text: "Zieltemperatur",
|
text: "Zieltemperatur",
|
||||||
icon: mdi("oil-temperature"),
|
icon: mdi("oil-temperature"),
|
||||||
|
|
@ -361,8 +319,8 @@ const config: Config = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "slider",
|
type: "slider",
|
||||||
min: 10,
|
min: 15,
|
||||||
max: 21.5,
|
max: 25,
|
||||||
step: 0.1,
|
step: 0.1,
|
||||||
text: "Zieltemperatur",
|
text: "Zieltemperatur",
|
||||||
icon: mdi("oil-temperature"),
|
icon: mdi("oil-temperature"),
|
||||||
|
|
@ -370,10 +328,58 @@ const config: Config = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
tucana: {
|
||||||
|
name: "tucana",
|
||||||
|
position: [110, 658],
|
||||||
|
icon: mdi("desktop-tower"),
|
||||||
|
iconColor: ({tucanaPower}) =>
|
||||||
|
({
|
||||||
|
"Link Down": hex("#888888"),
|
||||||
|
"1000M": hex("#00ff00"),
|
||||||
|
"10M": hex("#000000")
|
||||||
|
})[tucanaPower] || hex("#ff0000"),
|
||||||
|
ui: [
|
||||||
|
{
|
||||||
|
type: "toggle",
|
||||||
|
topic: "tucanaPower",
|
||||||
|
text: "Einschalten",
|
||||||
|
icon: mdi("power"),
|
||||||
|
on: "1000M"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: "Link Speed",
|
||||||
|
icon: mdi("ethernet"),
|
||||||
|
topic: "tucanaPower"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
officeSwitch: {
|
||||||
|
name: "Switch Büro",
|
||||||
|
position: [200, 540],
|
||||||
|
icon: mdi("lan"),
|
||||||
|
ui: [
|
||||||
|
{
|
||||||
|
type: "toggle",
|
||||||
|
topic: "officeSwitchPollingActive",
|
||||||
|
text: "Poll switch status",
|
||||||
|
icon: mdi("power")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "link",
|
||||||
|
link: "http://192.168.0.189/",
|
||||||
|
text: "Open Webinterface",
|
||||||
|
icon: mdi("open-in-new")
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
officeLight: {
|
officeLight: {
|
||||||
name: "Büro",
|
name: "Büro",
|
||||||
position: [210, 570],
|
position: [210, 570],
|
||||||
icon: mdi("ceiling-light"),
|
icon: mdi("ceiling-light"),
|
||||||
|
iconColor: ({officeState}) =>
|
||||||
|
(officeState === "on" ? hex("#00FF00") : hex("#000000")),
|
||||||
ui: [
|
ui: [
|
||||||
{
|
{
|
||||||
type: "toggle",
|
type: "toggle",
|
||||||
|
|
@ -387,7 +393,7 @@ const config: Config = {
|
||||||
max: 255,
|
max: 255,
|
||||||
text: "Helligkeit",
|
text: "Helligkeit",
|
||||||
icon: mdi("brightness-7"),
|
icon: mdi("brightness-7"),
|
||||||
topic: "officeBrightness"
|
topic: "officebrightness"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -395,6 +401,8 @@ const config: Config = {
|
||||||
name: "Flur",
|
name: "Flur",
|
||||||
position: [520, 370],
|
position: [520, 370],
|
||||||
icon: mdi("ceiling-light"),
|
icon: mdi("ceiling-light"),
|
||||||
|
iconColor: ({hallwayState}) =>
|
||||||
|
(hallwayState === "on" ? hex("#00FF00") : hex("#000000")),
|
||||||
ui: [
|
ui: [
|
||||||
{
|
{
|
||||||
type: "toggle",
|
type: "toggle",
|
||||||
|
|
@ -408,7 +416,64 @@ const config: Config = {
|
||||||
max: 255,
|
max: 255,
|
||||||
text: "Helligkeit",
|
text: "Helligkeit",
|
||||||
icon: mdi("brightness-7"),
|
icon: mdi("brightness-7"),
|
||||||
topic: "hallwayBrightness"
|
topic: "hallwaybrightness"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
hallway2Light: {
|
||||||
|
name: "Flur",
|
||||||
|
position: [250, 370],
|
||||||
|
icon: mdi("ceiling-light"),
|
||||||
|
iconColor: ({hallway2State}) =>
|
||||||
|
(hallway2State === "on" ? hex("#00FF00") : hex("#000000")),
|
||||||
|
ui: [
|
||||||
|
{
|
||||||
|
type: "toggle",
|
||||||
|
topic: "hallway2State",
|
||||||
|
text: "Ein/Ausschalten",
|
||||||
|
icon: mdi("power")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "slider",
|
||||||
|
min: 0,
|
||||||
|
max: 255,
|
||||||
|
text: "Helligkeit",
|
||||||
|
icon: mdi("brightness-7"),
|
||||||
|
topic: "hallway2brightness"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
pi: {
|
||||||
|
name: "Pi",
|
||||||
|
position: [550, 75],
|
||||||
|
icon: mdi("raspberrypi"),
|
||||||
|
ui: [
|
||||||
|
{
|
||||||
|
type: "toggle",
|
||||||
|
topic: "lueftenHint",
|
||||||
|
text: "Lüften Erinnerung",
|
||||||
|
icon: mdi("fan")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "link",
|
||||||
|
link: "http://192.168.0.12:3000/",
|
||||||
|
text: "Grafana",
|
||||||
|
icon: mdi("open-in-new")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
nas: {
|
||||||
|
name: "NAS",
|
||||||
|
position: [550, 100],
|
||||||
|
icon: mdi("nas"),
|
||||||
|
iconColor: ({nasPower}) =>
|
||||||
|
(nasPower === "on" ? hex("#00FF00") : hex("#000000")),
|
||||||
|
ui: [
|
||||||
|
{
|
||||||
|
type: "toggle",
|
||||||
|
topic: "nasPower",
|
||||||
|
text: "Einschalten",
|
||||||
|
icon: mdi("power")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -416,6 +481,8 @@ const config: Config = {
|
||||||
name: "Wohnzimmer",
|
name: "Wohnzimmer",
|
||||||
position: [450, 200],
|
position: [450, 200],
|
||||||
icon: mdi("ceiling-light"),
|
icon: mdi("ceiling-light"),
|
||||||
|
iconColor: ({livingroomState}) =>
|
||||||
|
(livingroomState === "on" ? hex("#00FF00") : hex("#000000")),
|
||||||
ui: ([
|
ui: ([
|
||||||
{
|
{
|
||||||
type: "toggle",
|
type: "toggle",
|
||||||
|
|
@ -435,7 +502,7 @@ const config: Config = {
|
||||||
max: 255,
|
max: 255,
|
||||||
text: "Helligkeit",
|
text: "Helligkeit",
|
||||||
icon: mdi("brightness-7"),
|
icon: mdi("brightness-7"),
|
||||||
topic: "livingroomBrightness"
|
topic: "livingroombrightness"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "slider",
|
type: "slider",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue