diff --git a/time-based/light-level-filter.js b/time-based/light-level-filter.js index fa05b1e..78823c4 100644 --- a/time-based/light-level-filter.js +++ b/time-based/light-level-filter.js @@ -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'}) } \ No newline at end of file