@Jdruwe those example lights on/off flows never work. Lux changes up and when the continued motion on the sensor occurs, beucase you dont have any condition checks in place, the flow says lux is to high therefore turn off. Have a look at my flow below - it seems complex but isnt when you work through it (as you can see, I also have my own mode manager built to handle whichever mode the house is in as to what level to set the bulbs to). I also have an automation override being as theres times when you want the light to come on and stay on, or stay off even with motion; I can control these from Apple Homekit as switches.
My updated ZHA flow, with average lux settings (becuase I have 2 Hue motion sensors, using just one of the motion sensors lux value causes a race condition (the first sensor updates lux on motion however being as the light is then on by the time sensor 2 pickups up movement and updates lux it creates a conflict of lux values and the flow then thinks lux is higher than the trigger - hope that makes sense?):
[{"id":"f6de963f.d74b78","type":"tab","label":"Downstairs Hall","disabled":false,"info":""},{"id":"48dfdbf9.6418a4","type":"comment","z":"f6de963f.d74b78","name":"Turn off automation","info":"","x":130,"y":360,"wires":[]},{"id":"9234f274.ab90a","type":"server-state-changed","z":"f6de963f.d74b78","name":"Downstairs hall automation off","server":"9f14629c.16082","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.downstairs_hall_automation","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":160,"y":400,"wires":[["6348f373.e4265c"],[]]},{"id":"6348f373.e4265c","type":"change","z":"f6de963f.d74b78","name":"Stop timer","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"STOP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":400,"wires":[["954ddac8.cdf8f8"]]},{"id":"954ddac8.cdf8f8","type":"link out","z":"f6de963f.d74b78","name":"Cancel Timer","links":["ffb00bfc.08da28","b2741f1c.d6407","e6986fc6.5f82c","4a035e26.5930c","7ae27367.1e67fc"],"x":595,"y":400,"wires":[]},{"id":"eca95a35.6b67f8","type":"comment","z":"f6de963f.d74b78","name":"Turn on automation","info":"","x":130,"y":480,"wires":[]},{"id":"a94d71a1.aa4db","type":"server-state-changed","z":"f6de963f.d74b78","name":"Downstairs hall automation on","server":"9f14629c.16082","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.downstairs_hall_automation","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,"x":160,"y":520,"wires":[["ec1c7154.04d3c"],[]]},{"id":"ec1c7154.04d3c","type":"link out","z":"f6de963f.d74b78","name":"Resume timer","links":["ffb00bfc.08da28","b2741f1c.d6407","d48a7fa7.972","e6986fc6.5f82c","4a035e26.5930c","7ae27367.1e67fc"],"x":375,"y":520,"wires":[]},{"id":"8304418d.27c39","type":"api-current-state","z":"f6de963f.d74b78","name":"light on?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.downstairs_hall_lights","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":840,"y":180,"wires":[[],["e19afa60.131d28"]]},{"id":"3bb1279.b24a5d8","type":"api-current-state","z":"f6de963f.d74b78","name":"Automation enabled?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.downstairs_hall_automation","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1320,"y":440,"wires":[["c9b6eac3.553eb8"],[]]},{"id":"15459e08.c79f22","type":"api-call-service","z":"f6de963f.d74b78","name":"ON","server":"9f14629c.16082","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.downstairs_hall_lights","data":"{\"brightness_pct\":60,\"kelvin\":3200,\"transition\":0.1}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1530,"y":40,"wires":[[]]},{"id":"cc27df77.fea99","type":"api-current-state","z":"f6de963f.d74b78","name":"Evening?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.ha_mode_evening","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1282,"y":40,"wires":[["15459e08.c79f22"],[]]},{"id":"f9cff041.61eb7","type":"api-current-state","z":"f6de963f.d74b78","name":"Midweek?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.ha_mode_midweek","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1283,"y":100,"wires":[["ee280123.73bea"],[]]},{"id":"d450c1c3.9d97b","type":"api-current-state","z":"f6de963f.d74b78","name":"Midweek morning?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.ha_mode_midweek_morning","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1310,"y":280,"wires":[["f586b1bd.6bcae"],[]]},{"id":"5e2888e8.1136a8","type":"api-current-state","z":"f6de963f.d74b78","name":"Weekend?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.ha_mode_weekend","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1290,"y":160,"wires":[["ee280123.73bea"],[]]},{"id":"21b04558.6ee26a","type":"api-current-state","z":"f6de963f.d74b78","name":"Weekend morning?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.ha_mode_weekend_morning","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1310,"y":220,"wires":[["76897972.ac2c68"],[]]},{"id":"ee280123.73bea","type":"api-call-service","z":"f6de963f.d74b78","name":"ON","server":"9f14629c.16082","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.downstairs_hall_lights","data":"{\"brightness_pct\":100,\"kelvin\":3200,\"transition\":0.1}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1530,"y":120,"wires":[[]]},{"id":"76897972.ac2c68","type":"api-call-service","z":"f6de963f.d74b78","name":"ON","server":"9f14629c.16082","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.downstairs_hall_lights","data":"{\"brightness_pct\":50,\"kelvin\":3200,\"transition\":0.1}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1530,"y":220,"wires":[[]]},{"id":"5dbf758a.dec3ac","type":"api-current-state","z":"f6de963f.d74b78","name":"Night??","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.ha_mode_night","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1280,"y":340,"wires":[["f586b1bd.6bcae"],[]]},{"id":"f586b1bd.6bcae","type":"api-call-service","z":"f6de963f.d74b78","name":"ON","server":"9f14629c.16082","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.downstairs_hall_lights","data":"{\"brightness_pct\":10,\"kelvin\":3200,\"transition\":0.1}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1530,"y":300,"wires":[[]]},{"id":"c9b6eac3.553eb8","type":"api-call-service","z":"f6de963f.d74b78","name":"OFF","server":"9f14629c.16082","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.downstairs_hall_lights","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1550,"y":440,"wires":[[]]},{"id":"b2741f1c.d6407","type":"link in","z":"f6de963f.d74b78","name":"Downstairs hall continued","links":["ec1c7154.04d3c","954ddac8.cdf8f8"],"x":695,"y":340,"wires":[["317b2829.d36ff8"]]},{"id":"36a3e84d.be8ea8","type":"switch","z":"f6de963f.d74b78","name":"Lux threshold 30 or less","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"30","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1130,"y":720,"wires":[["3cddc65.727213a"],["a10347f.f2258b8"]]},{"id":"3cddc65.727213a","type":"change","z":"f6de963f.d74b78","name":"Enable light","rules":[{"t":"set","p":"light_enabled","pt":"flow","to":"yes","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1350,"y":700,"wires":[["650d52da.3c6efc"]]},{"id":"a10347f.f2258b8","type":"change","z":"f6de963f.d74b78","name":"Disable light","rules":[{"t":"set","p":"light_enabled","pt":"flow","to":"no","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1350,"y":740,"wires":[["ab6d9389.3617e"]]},{"id":"650d52da.3c6efc","type":"debug","z":"f6de963f.d74b78","name":"Enable Light","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1540,"y":700,"wires":[]},{"id":"ab6d9389.3617e","type":"debug","z":"f6de963f.d74b78","name":"Disable light","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1542,"y":740,"wires":[]},{"id":"e19afa60.131d28","type":"switch","z":"f6de963f.d74b78","name":"Light enabled?","property":"light_enabled","propertyType":"flow","rules":[{"t":"eq","v":"yes","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1020,"y":180,"wires":[["cc27df77.fea99","f9cff041.61eb7","5e2888e8.1136a8","21b04558.6ee26a","d450c1c3.9d97b","5dbf758a.dec3ac"]]},{"id":"69ee6846.c85b38","type":"comment","z":"f6de963f.d74b78","name":"Downstairs Hall Lux","info":"Store lux values when hall light is off","x":130,"y":600,"wires":[]},{"id":"59775a8b.5483f4","type":"api-current-state","z":"f6de963f.d74b78","name":"All Away?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.ha_mode_away","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":380,"y":260,"wires":[[],["defbfab8.cfd2c8"]]},{"id":"defbfab8.cfd2c8","type":"api-current-state","z":"f6de963f.d74b78","name":"Automation enabled?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.downstairs_hall_automation","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":580,"y":260,"wires":[["317b2829.d36ff8","8304418d.27c39"],[]]},{"id":"a25b01ce.9793b","type":"server-state-changed","z":"f6de963f.d74b78","name":"Front Door Motion","server":"9f14629c.16082","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.front_door_sensor_motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":130,"y":220,"wires":[["59775a8b.5483f4"]]},{"id":"f8b47115.05be1","type":"server-state-changed","z":"f6de963f.d74b78","name":"Downstairs Hall Motion","server":"9f14629c.16082","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.downstairs_hall_sensor_motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":140,"y":280,"wires":[["59775a8b.5483f4"]]},{"id":"317b2829.d36ff8","type":"stoptimer","z":"f6de963f.d74b78","duration":"30","units":"Second","payloadtype":"num","payloadval":"2","name":"","x":870,"y":320,"wires":[["94e90718.d86368"],[]]},{"id":"94e90718.d86368","type":"api-current-state","z":"f6de963f.d74b78","name":"DH Hall motion on?","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.downstairs_hall_sensor_motion","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1090,"y":400,"wires":[[],["3bb1279.b24a5d8"]]},{"id":"ff7e3e19.3c892","type":"link in","z":"f6de963f.d74b78","name":"Reset Light Timer In","links":["1c0d8020.638e9"],"x":755,"y":400,"wires":[["317b2829.d36ff8"]]},{"id":"ec30229.c3a0e6","type":"server-state-changed","z":"f6de963f.d74b78","name":"Front door","server":"9f14629c.16082","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.front_door_sensor_light","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":120,"y":660,"wires":[["d28eb865.5afea"]]},{"id":"96af0824.8851e8","type":"server-state-changed","z":"f6de963f.d74b78","name":"Downstairs Hall","server":"9f14629c.16082","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.downstairs_hall_sensor_light","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":100,"y":760,"wires":[["1d4fe5be.f34942"]]},{"id":"1d4fe5be.f34942","type":"change","z":"f6de963f.d74b78","name":"","rules":[{"t":"set","p":"DHLux","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":760,"wires":[["c6d7af90.df2538"]]},{"id":"d28eb865.5afea","type":"change","z":"f6de963f.d74b78","name":"","rules":[{"t":"set","p":"FDLux","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":660,"wires":[["c6d7af90.df2538"]]},{"id":"c6d7af90.df2538","type":"api-current-state","z":"f6de963f.d74b78","name":"DH Light Off","server":"9f14629c.16082","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.downstairs_hall_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":490,"y":720,"wires":[["ba4d3ef1.cb59","decb38f6.0c29c"],[]]},{"id":"decb38f6.0c29c","type":"change","z":"f6de963f.d74b78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"FDLux","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":660,"wires":[["db5cfdfd.b6f218"]]},{"id":"ba4d3ef1.cb59","type":"change","z":"f6de963f.d74b78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"DHLux","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":780,"wires":[["db5cfdfd.b6f218"]]},{"id":"db5cfdfd.b6f218","type":"average","z":"f6de963f.d74b78","name":"","topic":"","x":920,"y":720,"wires":[["36a3e84d.be8ea8"]]},{"id":"9f14629c.16082","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
The average node is using node-red-contrib-average