add button for wled office auto on/off

This commit is contained in:
Ranlvor 2022-11-15 17:56:52 +01:00
parent 58c9ae1125
commit 8e002e3b1a
Signed by untrusted user who does not match committer: Ranlvor
GPG key ID: 5E12D04750EF6F8E

View file

@ -56,14 +56,17 @@ const topicBulbNumber = (bulb: string, parameter: string) => topicZigbeeNumber(b
const topicGroupNumber = (bulb: string, parameter: string) => topicZigbeeNumber(bulb, `group_${bulb}`, parameter); const topicGroupNumber = (bulb: string, parameter: string) => topicZigbeeNumber(bulb, `group_${bulb}`, parameter);
const topicHomeBoolean = (name: string, topic: string, const topicHomeBoolean = (name: string, topic: string,
defaultValue: boolean = false) => topicBoolean(name, `home-rust/${topic}`, defaultValue);
const topicBoolean = (name: string, topic: string,
defaultValue: boolean = false) => ({ defaultValue: boolean = false) => ({
[`${name}`]: { [`${name}`]: {
state: { state: {
name: `home-rust/${topic}`, name: `${topic}`,
type: types.option({ true: "on", false: "off" }) type: types.option({ true: "on", false: "off" })
}, },
command: { command: {
name: `home-rust/${topic}/set`, name: `${topic}/set`,
type: types.option({ on: "true", off: "false" }) type: types.option({ on: "true", off: "false" })
}, },
defaultValue: defaultValue ? "on" : "off" defaultValue: defaultValue ? "on" : "off"
@ -325,6 +328,8 @@ const config: Config = {
...topicHomeBoolean("officeSwitchPollingActive", "switch/office/polling", ...topicHomeBoolean("officeSwitchPollingActive", "switch/office/polling",
true), true),
...topicBoolean("wledOfficeAuto", "wled/office/automatic"),
...topicTasmota("fanBedroom", "sonoff-bedroom-fan"), ...topicTasmota("fanBedroom", "sonoff-bedroom-fan"),
...topicTasmota("fanOffice", "sonoff-office-fan"), ...topicTasmota("fanOffice", "sonoff-office-fan"),
...topicTasmota("tasmotaProjector", "tasmota-projector"), ...topicTasmota("tasmotaProjector", "tasmota-projector"),
@ -671,8 +676,8 @@ const config: Config = {
name: "Jalousien Büro", name: "Jalousien Büro",
position: [170,658], position: [170,658],
icon: withState((s) => ( icon: withState((s) => (
(s["officeBlindLeftposition"] <= 9 && (parseInt(s["officeBlindLeftposition"]) <= 9 &&
s["officeBlindRightposition"] <= 9) ? parseInt(s["officeBlindRightposition"]) <= 9) ?
svg(icons.mdiBlindsOpen) : svg(icons.mdiBlindsOpen) :
svg(icons.mdiBlinds) svg(icons.mdiBlinds)
)), )),
@ -920,6 +925,12 @@ const config: Config = {
off: "0", off: "0",
toggled: (n) => parseInt(n, 10) > 0 toggled: (n) => parseInt(n, 10) > 0
}, },
{
type: "toggle",
topic: "wledOfficeAuto",
text: "Automatik",
icon: svg(icons.mdiAutoDownload)
},
{ {
type: "slider", type: "slider",
min: 1, min: 1,