Add event fire to time-based automation flow for HA automation use

This commit is contained in:
2023-12-20 17:05:59 -05:00
parent 90effd6b2b
commit e71c839bea

View File

@ -24,11 +24,14 @@ node.log("Time-based Automations: Constants Set")
let time = {}
let topic = {}
let delay = {}
let eventCall = {}
if (payload == 0 || payload === 'weather') {
time = "night"
eventCall = "on"
} else if (payload == 1) {
time = "day"
eventCall = "off"
}
if (msg.topic === 'timer-finished' || msg.topic === 'manual-trigger' || msg.topic === 'weather') {
@ -322,6 +325,15 @@ let sendDeskScene = {
}
}
let sendExtraLights = {
"payload": {
"event": "extraLights",
"data": {
"toggle": eventCall
}
}
}
node.log("Time-based Automations: Message Payloads Defined")
node.log("----- Time-based Automations: Set Parameters")
@ -331,6 +343,7 @@ node.log("lightsOff: " + lightsOff)
node.log("stairKelvin: " + stairKelvin)
node.log("stairBrt: " + stairBrt)
node.log("holidayMode: " + holidayMode)
node.log("eventCall: " + eventCall)
if (time === 'night') {
node.log("weather: " + weather)
node.log("delay: " + delay)
@ -347,33 +360,33 @@ node.log("----- Time-based Automations: End Parameters -----")
if (vacation === 'off') {
if (time === "day") {
node.status({fill:"green",shape:"dot",text:"Sunrise Flow"})
node.send([null,[sendLights,sendBooleanOff],sendStairwellScript])
node.send([null,[sendLights,sendBooleanOff],sendStairwellScript,sendExtraLights])
setTimeout(() => {
node.send([null,[sendStairwellOff,sendSleepOff,sendAdaptive,sendSceneResetMain,sendSceneResetDesk],null])
node.send([null,[sendStairwellOff,sendSleepOff,sendAdaptive,sendSceneResetMain,sendSceneResetDesk],null,null])
if (holidayMode === 'on' && holidayHold === 'off') {
node.send([null,[sendHoliday],null])
node.send([null,[sendHoliday],null,null])
}
}, 5000)
} else if (time === "night") {
node.status({fill:"green",shape:"dot",text:"Sunset Flow"})
node.send([null,sendAdaptive,null])
node.send([null,sendAdaptive,null,null])
if (holidayMode === 'on') {
setTimeout(() => {
node.send([null,sendHoliday,null])
node.send([null,sendHoliday,null,null])
}, 1000)
}
if (delay === 'on') {
node.send([null,sendTimer,null])
node.send([null,sendTimer,null,null])
} else {
if (topic === 'weather') {
node.send([null,sendTimerCancel,null])
node.send([null,sendTimerCancel,null,null])
}
node.send([null,null,[sendFirstFloorScene,sendSecondFloorScene]])
node.send([null,null,[sendFirstFloorScene,sendSecondFloorScene],null])
if (deskLights === 'on') {
node.send([null,sendDeskScene,null])
node.send([null,sendDeskScene,null,null])
}
if (topic != 'manual-trigger') {
node.send([[sendNotifyPhone,sendNotifyTV],null,null])
node.send([[sendNotifyPhone,sendNotifyTV],null,null,null])
}
}
}