Best practice - controlling light by motion

Hey boys and girls,

im using home assistant already about 5 years and love it all over. Since i switched from Raspbee 1 to zha with sky connect i notice problems with stable connections to my motion sensors. I used node-red so far for controlling my lights with the motions sensors but im aksing myself how the community is controlling the lights connected to a motion sensor and what could be the best practice and what is a good solution if the motion sensor disconnects while the light is powered. I put my flow into this thread. (Im not a coder and teached the stuff all to myself) The flow shows on the right side the toggle on and at the bottom the way to dim down the light by time if no motion is detected.

[{"id":"f99d6e0d.472d48","type":"tab","label":"Motion Flur unten","disabled":false,"info":""},{"id":"1d560030.f49118","type":"api-call-service","z":"f99d6e0d.472d48","name":"Deckenlampe LichtAN 50%","server":"1f61e283.c4968d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.ikea_2"],"data":"{\"brightness_pct\":\"50\",\"transition\":\"3\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1000,"y":120,"wires":[[]]},{"id":"f621801b.e9b34","type":"api-call-service","z":"f99d6e0d.472d48","name":"LichtAN 20%","server":"1f61e283.c4968d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.ikea_2"],"data":"{\"brightness_pct\":\"20\",\"transition\":\"3\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1020,"y":260,"wires":[[]]},{"id":"37b8a64a.0446b2","type":"time-range-switch","z":"f99d6e0d.472d48","name":"Zeitcheck","lat":"54.159","lon":"10.02726","startTime":"06:30","endTime":"22:30","startOffset":0,"endOffset":0,"x":820,"y":240,"wires":[["1d560030.f49118"],["f621801b.e9b34"]]},{"id":"f93b70af.773a7","type":"api-current-state","z":"f99d6e0d.472d48","name":"Deckenlampe an?","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.ikea_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":270,"y":280,"wires":[["70693422.140cc4"],[]]},{"id":"331fdf87.f78b88","type":"api-call-service","z":"f99d6e0d.472d48","name":"Licht auf 10%","server":"1f61e283.c4968d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.ikea_2"],"data":"{\"brightness_pct\":\"10\",\"transition\":\"3\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":300,"y":700,"wires":[["e3cc6d12284ea9c4"]]},{"id":"ae2eba4.00d5148","type":"api-call-service","z":"f99d6e0d.472d48","name":"Licht aus","server":"1f61e283.c4968d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.ikea_2"],"data":"{\"brightness_pct\":\"0\",\"transition\":\"3\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":280,"y":940,"wires":[[]]},{"id":"bd6d371a.4d9a3","type":"api-call-service","z":"f99d6e0d.472d48","name":"Licht auf 5%","server":"1f61e283.c4968d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.ikea_2"],"data":"{\"brightness_pct\":\"1\",\"transition\":\"5\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":570,"y":700,"wires":[["bbc1cdf7a6023d53"]]},{"id":"cabb3e00.735268","type":"api-call-service","z":"f99d6e0d.472d48","name":"Licht aus","server":"1f61e283.c4968d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.ikea_2"],"data":"{\"brightness_pct\":\"0\",\"transition\":\"3\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":560,"y":940,"wires":[[]]},{"id":"70693422.140cc4","type":"api-current-state","z":"f99d6e0d.472d48","name":"Tag oder Nacht","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"above_horizon","halt_if_type":"str","halt_if_compare":"is","entity_id":"sun.sun","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":260,"y":360,"wires":[["0a45bfa95da0a5b1"],["4fac87d5.94389"]]},{"id":"4fac87d5.94389","type":"time-range-switch","z":"f99d6e0d.472d48","name":"Zeitcheck","lat":"","lon":"","startTime":"05:30","endTime":"23:00","startOffset":0,"endOffset":0,"x":240,"y":420,"wires":[["0a45bfa95da0a5b1"],["943a330cdb8e2d6e"]]},{"id":"ec4596d9.9ab608","type":"api-current-state","z":"f99d6e0d.472d48","name":"Motion?","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.motion_aq_1","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":280,"y":640,"wires":[["331fdf87.f78b88"],["0a45bfa95da0a5b1"]]},{"id":"bac53dc8.7d8b08","type":"api-current-state","z":"f99d6e0d.472d48","name":"Motion?","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.motion_aq_1","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":280,"y":880,"wires":[["ae2eba4.00d5148"],["e3cc6d12284ea9c4"]]},{"id":"32cdb56d.549caa","type":"api-current-state","z":"f99d6e0d.472d48","name":"Motion?","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.motion_aq_1","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":560,"y":640,"wires":[["bd6d371a.4d9a3"],["943a330cdb8e2d6e"]]},{"id":"d3aa7643.95a3d8","type":"api-current-state","z":"f99d6e0d.472d48","name":"Motion?","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.motion_aq_1","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":560,"y":880,"wires":[["cabb3e00.735268"],["bbc1cdf7a6023d53"]]},{"id":"ca881a56.4d4108","type":"api-current-state","z":"f99d6e0d.472d48","name":"Deckenlampe an?","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.ikea_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":310,"y":580,"wires":[["ec4596d9.9ab608"],[]]},{"id":"733919db.6fc3c8","type":"api-current-state","z":"f99d6e0d.472d48","name":"Deckenlampe an?","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.ikea_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":310,"y":820,"wires":[["bac53dc8.7d8b08"],[]]},{"id":"e2d974b6.ed7e78","type":"api-current-state","z":"f99d6e0d.472d48","name":"Deckenlampe an?","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.ikea_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":590,"y":820,"wires":[["d3aa7643.95a3d8"],[]]},{"id":"5cadf79b.3ef678","type":"api-current-state","z":"f99d6e0d.472d48","name":"Deckenlampe an?","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.ikea_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":590,"y":580,"wires":[["32cdb56d.549caa"],[]]},{"id":"0a45bfa95da0a5b1","type":"delay","z":"f99d6e0d.472d48","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":300,"y":520,"wires":[["ca881a56.4d4108"]]},{"id":"943a330cdb8e2d6e","type":"delay","z":"f99d6e0d.472d48","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":550,"y":520,"wires":[["5cadf79b.3ef678"]]},{"id":"e3cc6d12284ea9c4","type":"delay","z":"f99d6e0d.472d48","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":290,"y":760,"wires":[["733919db.6fc3c8"]]},{"id":"bbc1cdf7a6023d53","type":"delay","z":"f99d6e0d.472d48","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":560,"y":760,"wires":[["e2d974b6.ed7e78"]]},{"id":"f0eaa463d27d703d","type":"server-state-changed","z":"f99d6e0d.472d48","name":"Motion Flur","server":"1f61e283.c4968d","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.motion_aq_1","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":150,"y":140,"wires":[["949ee0b3b3d3fa1a","651d83f2da875f53"],["f93b70af.773a7"]]},{"id":"949ee0b3b3d3fa1a","type":"api-current-state","z":"f99d6e0d.472d48","name":"light level < 35","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"35","halt_if_type":"num","halt_if_compare":"lt","entity_id":"sensor.aq_lux_1","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":400,"y":80,"wires":[["1aa38f06.fe5b39"],[]]},{"id":"1aa38f06.fe5b39","type":"api-current-state","z":"f99d6e0d.472d48","name":"Tag oder Nacht","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"above_horizon","halt_if_type":"str","halt_if_compare":"is","entity_id":"sun.sun","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":660,"y":140,"wires":[["1d560030.f49118"],["37b8a64a.0446b2"]]},{"id":"651d83f2da875f53","type":"api-current-state","z":"f99d6e0d.472d48","name":"Deckenlampe an?","server":"1f61e283.c4968d","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.ikea_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":410,"y":160,"wires":[["1aa38f06.fe5b39"],[]]},{"id":"1f61e283.c4968d","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

I do not use node-red. I do everything only via HA itself. Also my sensors do not disconnect. If they do, I get a message via signal on my phone.