Hi Guys, need some help here as I am new to motion lights automation.
I have a motion sensor and I want to trigger the light to turn on after 15s, and it will turn off if no presence detected after 30s (for example).
I used the trigger to wait 30s to turn lights off and if msg.payload is on then reset the trigger. This works ok initially but I found out that there’re scenarios the msg.payload couldn’t send it quickly enough to cancel the trigger timer (since I have set the condition to turn on as 15s). So sometimes the light will turn off and turn on even there’s presence. Is there any way to improve this? Thanks.
[{"id":"c1200a75d886372c","type":"api-call-service","z":"77a82869577d2280","name":"","server":"ab275ce0.0e1d7","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":["b2c373f45b480a4d4ba260433327d28b"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":830,"y":540,"wires":[[]]},{"id":"37593fc5d17ecfd9","type":"server-state-changed","z":"77a82869577d2280","name":"Sensor Zone 1 is ON for 15s","server":"ab275ce0.0e1d7","version":5,"outputs":2,"exposeAsEntityConfig":"05c648e743c02a9e","entityId":"binary_sensor.presence_sensor_fp2_81af_zone_1","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"on","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"15","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":520,"wires":[["e9e91a1b08ad1ca6"],["e9e91a1b08ad1ca6"]]},{"id":"1bc5e9343099b801","type":"trigger","z":"77a82869577d2280","name":"","op1":"","op2":"10s test","op1type":"nul","op2type":"str","duration":"30","extend":true,"overrideDelay":false,"units":"s","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":630,"y":540,"wires":[["c1200a75d886372c"]]},{"id":"e9e91a1b08ad1ca6","type":"switch","z":"77a82869577d2280","name":"ON or OFF","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":520,"wires":[["187596e180ab6f09","1bc5e9343099b801"],["1bc5e9343099b801"]]},{"id":"187596e180ab6f09","type":"api-call-service","z":"77a82869577d2280","name":"","server":"ab275ce0.0e1d7","version":5,"debugenabled":false,"domain":"scene","service":"turn_on","areaId":[],"deviceId":[],"entityId":["scene.dining_room_mavis_focus"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":640,"y":460,"wires":[[]]},{"id":"ab275ce0.0e1d7","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false},{"id":"05c648e743c02a9e","type":"ha-entity-config","server":"ab275ce0.0e1d7","deviceConfig":"","name":"Dining Light Zone 1 Motion","version":"6","entityType":"switch","haConfig":[{"property":"name","value":"Dining Light Zone 1 Motion"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false}]