HA Node Red lights on depending of illumination (lux)

Hello,

I started using Home Assistant a few days ago and at the moment it’s overwhelming. If anyone can help me a bit over here it will be insanely appreciated.

I did not understand how I can make the lights automatization I’m about to show in HA so I’ve tried doing it in Node-Red and it’s working but I need to introduce the illumination level into the flow so I need the automation to run only if the light in the room is below 100 lux.

At the moment I have this:

so I have two periods of time because I wanted different brightness and everything else is the same…the lights will turn on and stay on as long as it is motion. After the motion turns off than it waits 60 seconds before turning off the lights.

As I said above, I need to run this if the illumination in the room is below 100 lux.

Thank you and keep in mind I’m new to this :slight_smile:

[{"id":"773a8406e7e711eb","type":"server-state-changed","z":"894a6b3077af9604","name":"","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":344,"y":1472,"wires":[["ece658dcd1b8942a"],[]]},{"id":"ece658dcd1b8942a","type":"api-current-state","z":"894a6b3077af9604","name":"","server":"","version":3,"outputs":2,"halt_if":"100","halt_if_type":"num","halt_if_compare":"lt","entity_id":"sensor.lux","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":590,"y":1472,"wires":[["97897a529c58b009","073cfbf3eaa7e0ae"],["027e470bdee51a0d"]]},{"id":"97897a529c58b009","type":"time-range-switch","z":"894a6b3077af9604","name":"","lat":"","lon":"","startTime":"sunsetStart","endTime":"dusk","startOffset":0,"endOffset":0,"x":822,"y":1472,"wires":[["578373b26f214530"],[]]},{"id":"073cfbf3eaa7e0ae","type":"time-range-switch","z":"894a6b3077af9604","name":"","lat":"","lon":"","startTime":"sunsetStart","endTime":"dusk","startOffset":0,"endOffset":0,"x":822,"y":1424,"wires":[["eb435f39d2e8d652"],[]]},{"id":"eb435f39d2e8d652","type":"api-call-service","z":"894a6b3077af9604","name":"","server":"","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.light","data":"{\"brightness_pct\": 80}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1194,"y":1424,"wires":[[]]},{"id":"578373b26f214530","type":"change","z":"894a6b3077af9604","name":"set brightness","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\": {\"brightness_pct\": 50}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1008,"y":1472,"wires":[["eb435f39d2e8d652"]]},{"id":"027e470bdee51a0d","type":"ha-wait-until","z":"894a6b3077af9604","name":"","server":"","version":0,"outputs":2,"entityId":"light.light","entityIdFilterType":"exact","property":"state","comparator":"is","value":"off","valueType":"str","timeout":"60","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"data","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":796,"y":1520,"wires":[[],["f11f80c20ea9476e"]]},{"id":"f11f80c20ea9476e","type":"api-call-service","z":"894a6b3077af9604","name":"","server":"","version":3,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.light","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1018,"y":1520,"wires":[[]]}]

Thank you! A couple of questions if I may ask:

  1. wait until - do I replace light.light with the sensor motion? I need this to reset if motion is happening;
  2. can you please add a brightness dimming. I need the light to dim at half if there is no movement for 30 seconds and then if there is still no movement in 60 seconds to turn off.

I hope it’s not so much trouble and thanks again!