Add event fire to time-based automation flow for HA automation use
This commit is contained in:
@ -24,11 +24,14 @@ node.log("Time-based Automations: Constants Set")
|
|||||||
let time = {}
|
let time = {}
|
||||||
let topic = {}
|
let topic = {}
|
||||||
let delay = {}
|
let delay = {}
|
||||||
|
let eventCall = {}
|
||||||
|
|
||||||
if (payload == 0 || payload === 'weather') {
|
if (payload == 0 || payload === 'weather') {
|
||||||
time = "night"
|
time = "night"
|
||||||
|
eventCall = "on"
|
||||||
} else if (payload == 1) {
|
} else if (payload == 1) {
|
||||||
time = "day"
|
time = "day"
|
||||||
|
eventCall = "off"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.topic === 'timer-finished' || msg.topic === 'manual-trigger' || msg.topic === 'weather') {
|
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: Message Payloads Defined")
|
||||||
|
|
||||||
node.log("----- Time-based Automations: Set Parameters")
|
node.log("----- Time-based Automations: Set Parameters")
|
||||||
@ -331,6 +343,7 @@ node.log("lightsOff: " + lightsOff)
|
|||||||
node.log("stairKelvin: " + stairKelvin)
|
node.log("stairKelvin: " + stairKelvin)
|
||||||
node.log("stairBrt: " + stairBrt)
|
node.log("stairBrt: " + stairBrt)
|
||||||
node.log("holidayMode: " + holidayMode)
|
node.log("holidayMode: " + holidayMode)
|
||||||
|
node.log("eventCall: " + eventCall)
|
||||||
if (time === 'night') {
|
if (time === 'night') {
|
||||||
node.log("weather: " + weather)
|
node.log("weather: " + weather)
|
||||||
node.log("delay: " + delay)
|
node.log("delay: " + delay)
|
||||||
@ -347,33 +360,33 @@ node.log("----- Time-based Automations: End Parameters -----")
|
|||||||
if (vacation === 'off') {
|
if (vacation === 'off') {
|
||||||
if (time === "day") {
|
if (time === "day") {
|
||||||
node.status({fill:"green",shape:"dot",text:"Sunrise Flow"})
|
node.status({fill:"green",shape:"dot",text:"Sunrise Flow"})
|
||||||
node.send([null,[sendLights,sendBooleanOff],sendStairwellScript])
|
node.send([null,[sendLights,sendBooleanOff],sendStairwellScript,sendExtraLights])
|
||||||
setTimeout(() => {
|
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') {
|
if (holidayMode === 'on' && holidayHold === 'off') {
|
||||||
node.send([null,[sendHoliday],null])
|
node.send([null,[sendHoliday],null,null])
|
||||||
}
|
}
|
||||||
}, 5000)
|
}, 5000)
|
||||||
} else if (time === "night") {
|
} else if (time === "night") {
|
||||||
node.status({fill:"green",shape:"dot",text:"Sunset Flow"})
|
node.status({fill:"green",shape:"dot",text:"Sunset Flow"})
|
||||||
node.send([null,sendAdaptive,null])
|
node.send([null,sendAdaptive,null,null])
|
||||||
if (holidayMode === 'on') {
|
if (holidayMode === 'on') {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
node.send([null,sendHoliday,null])
|
node.send([null,sendHoliday,null,null])
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
if (delay === 'on') {
|
if (delay === 'on') {
|
||||||
node.send([null,sendTimer,null])
|
node.send([null,sendTimer,null,null])
|
||||||
} else {
|
} else {
|
||||||
if (topic === 'weather') {
|
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') {
|
if (deskLights === 'on') {
|
||||||
node.send([null,sendDeskScene,null])
|
node.send([null,sendDeskScene,null,null])
|
||||||
}
|
}
|
||||||
if (topic != 'manual-trigger') {
|
if (topic != 'manual-trigger') {
|
||||||
node.send([[sendNotifyPhone,sendNotifyTV],null,null])
|
node.send([[sendNotifyPhone,sendNotifyTV],null,null,null])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user