Include hallway in stairwell motion flow

This commit is contained in:
2024-01-24 14:23:09 -05:00
parent abc6857968
commit f5449aeb7b

View File

@ -4,16 +4,42 @@ const hallwayLights = states['light.hallway_overhead'].state
const earlyNightMode = states['binary_sensor.early_night_mode'].state const earlyNightMode = states['binary_sensor.early_night_mode'].state
const nightMode = states['input_boolean.night_mode'].state const nightMode = states['input_boolean.night_mode'].state
const goodnight = states['input_boolean.goodnight'].state const goodnight = states['input_boolean.goodnight'].state
const masterBedroomSleep = states['input_boolean.master_bedroom_sleeping'].state
const duration = states['input_number.stairwell_lights_off_delay'].state const duration = states['input_number.stairwell_lights_off_delay'].state
const lux = parseInt(states['sensor.stairwell_bottom_illuminance'].state) const lux = parseInt(states['sensor.stairwell_bottom_illuminance'].state)
const threshold = parseInt(states['input_number.stairwell_lux_threshold'].state) const threshold = parseInt(states['input_number.stairwell_lux_threshold'].state)
const payload = msg.payload const payload = msg.payload
const newDuration = duration * 60 const newDuration = duration * 60
let hallwayScene = {}
let hallwayAction = {}
if (payload === 'on') { if (payload === 'on') {
if (lux <= threshold || stairwellLights === 'on') { if (goodnight === 'on') {
hallwayAction = 'off'
} else if (nightMode === 'on' || masterBedroomSleep === 'on') {
hallwayAction = 'on'
hallwayScene = 'Dimmed'
} else if (earlyNightMode === 'on') {
hallwayAction = 'on'
hallwayScene = 'Adaptive'
} else {
hallwayAction = 'off'
}
}
msg.hallway = hallwayAction
msg.scene = hallwayScene
if (payload === 'on') {
if (lux <= threshold || stairwellLights === 'on' || hallwayLights === 'on') {
if (hallwayScene === 'Adaptive') {
node.send([null,null,msg,msg])
} else if (hallwayAction === 'on') {
node.send([null,null,msg,null])
}
node.status({fill:'green',shape:'dot',text:'Lights On'}) node.status({fill:'green',shape:'dot',text:'Lights On'})
node.send([msg,null]) node.send([msg,null,null,null])
} else { } else {
node.status({fill:'red',shape:'ring',text:'Too bright'}) node.status({fill:'red',shape:'ring',text:'Too bright'})
} }
@ -21,7 +47,7 @@ if (payload === 'on') {
if (stairwellLights === 'on') { if (stairwellLights === 'on') {
msg.duration = newDuration msg.duration = newDuration
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'}) node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
node.send([null,msg]) node.send([null,msg,null,null])
} else { } else {
node.status({fill:"red",shape:"ring",text:"Lights already off"}) node.status({fill:"red",shape:"ring",text:"Lights already off"})
} }