Rework light level filter node

home_automation/HA-NerdFlows#32
This commit is contained in:
2025-05-27 21:24:51 -04:00
parent 3a97da1b6d
commit 9f415eb232

View File

@ -1,18 +1,27 @@
const states = global.get('homeassistant.homeAssistant.states')
const luxThresholdLivingRoom = states['input_number.living_room_lux_threshold'].state
const luxThresholdStairwell = states['input_number.stairwell_lux_threshold'].state
const timer = states['timer.sunset_lighting_timer'].state
const luxThresholdOutdoor = states['input_number.sunset_lights_outdoor_lux_threshold'].state
const evening = states['binary_sensor.evening'].state
const triggered = states['input_boolean.sunset_lights_triggered'].state
const level = msg.level
const room = msg.room
if (timer === 'active') {
if (evening === 'on' && triggered === 'off') {
if (room === 'living-room' && level <= luxThresholdLivingRoom) {
node.status({fill:'green',shape:'dot',text:'Sent (Living Room)'})
node.send(msg)
node.send([msg,msg])
} else if (room === 'stairwell-bottom' && level <= luxThresholdStairwell) {
node.status({fill:'green',shape:'dot',text:'Sent (Stairwell Bottom)'})
node.send(msg)
node.send([msg,msg])
} else if (room === 'outdoor' && level <= luxThresholdOutdoor) {
node.status({fill:'green',shape:'dot',text:'Sent (Outdoor)'})
node.send([msg,msg])
}
} else if (evening === 'off') {
node.status({fill:'red',shape:'ring',text:'Not Evening'})
} else if (triggered === 'on') {
node.status({fill:'red',shape:'ring',text:'Already Triggered'})
} else {
node.status({fill:'red',shape:'ring',text:'Blocked'})
node.status({fill:'red',shape:'ring',text:'No Action'})
}