Here are the problems.
- My Node Red Kung-Fu is weak on my best day.
- This works but I think there is probably a better way.
Looking for a cleaner way to do this, any and all help is greatly appreciated. TIA.
What currently happens is I open the door to the garage (open/close sensor) garage lights turn on. then a 2 min timer starts, there is a Xiaomi motion sensor and a Tuya mm sensor ( the big black box ugly one) that are looking for motion/presence as long as there is the timer just restarts and lights stay on. This is a HA automation that I will move over to NR later. THEN the below flow is used to shut the lights off. It works but I am looking for suggestions on any way to make it better / cleaner.
Here is the flow:
[{"id":"37f25243aafd7916","type":"inject","z":"1901f90f9d7a2bc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":600,"wires":[["ce92135af17dbd41"]]},{"id":"ce92135af17dbd41","type":"api-current-state","z":"1901f90f9d7a2bc8","name":"Timer","server":"f4926e3aa78cdd4c","version":3,"outputs":2,"halt_if":"idle","halt_if_type":"str","halt_if_compare":"is","entity_id":"timer.garage_timer","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":270,"y":600,"wires":[["2cdc1b8f7ea7f5a2"],[]]},{"id":"2cdc1b8f7ea7f5a2","type":"api-current-state","z":"1901f90f9d7a2bc8","name":"Motion-top","server":"f4926e3aa78cdd4c","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.ts0601_human_presence_sensor_presence","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":290,"y":660,"wires":[["61e899a5678997cb"],[]]},{"id":"61e899a5678997cb","type":"api-current-state","z":"1901f90f9d7a2bc8","name":"Motion-shelf","server":"f4926e3aa78cdd4c","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.garage_light_sensor_occupancy","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":290,"y":720,"wires":[["37329e565836e93f"],[]]},{"id":"37329e565836e93f","type":"api-call-service","z":"1901f90f9d7a2bc8","name":"","server":"f4926e3aa78cdd4c","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":["c834f7fc3843d24bfcc67dc2e53ab3b3"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":300,"y":780,"wires":[[]]},{"id":"f4926e3aa78cdd4c","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}]