Add timer-finished function for stairwell

This commit is contained in:
2024-01-24 13:33:19 -05:00
parent 07a69b985f
commit da15236ace

View File

@ -0,0 +1,32 @@
const states = global.get('homeassistant.homeAssistant.states')
const earlyNightMode = states['binary_sensor.early_night_mode'].state
const nightMode = states['input_boolean.night_mode'].state
const goodnight = states['input_boolean.goodnight'].state
const masterBedroomSleep = states['input_boolean.master_bedroom_sleeping'].state
let hallwayScene = {}
let hallwayAction = {}
if (goodnight === 'on') {
hallwayAction = 'off'
} else if (masterBedroomSleep === 'off' && (earlyNightMode === 'on' || nightMode === 'on')) {
hallwayAction = 'on'
hallwayScene = 'Nightlight'
} else {
hallwayAction = 'off'
}
msg.hallway = hallwayAction
// Turn off Stairwell LED Strip
node.send([msg,null])
// Hallway actions
if (hallwayAction === 'on') {
msg.scene = hallwayScene
node.status({fill:'green',shape:'dot',text:'Hallway ' + hallwayScene})
node.send([null,null,msg])
} else if (hallwayAction === 'off') {
node.status({fill:'green',shape:'dot',text:'Hallway Off'})
node.send([null,msg,null])
}