Files
HA-NerdFlows-Functions/time-based/light-level-filter.js

18 lines
786 B
JavaScript

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 level = msg.level
const room = msg.room
if (timer === 'active') {
if (room === 'living-room' && level <= luxThresholdLivingRoom) {
node.status({fill:'green',shape:'dot',text:'Sent (Living Room)'})
node.send(msg)
} else if (room === 'stairwell-bottom' && level <= luxThresholdStairwell) {
node.status({fill:'green',shape:'dot',text:'Sent (Stairwell Bottom)'})
node.send(msg)
}
} else {
node.status({fill:'red',shape:'ring',text:'Blocked'})
}