Light with sensor turn off

Hello,

I don’t undestand why my light turn off.

[{"id":"64315577e4fbe873","type":"server-state-changed","z":"bc4f7c9d8e2d107c","name":"Luz-CDB-RDC","server":"778cd90d.9f3698","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"binary_sensor.hue_motion_sensor_1_motion_3","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":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":100,"y":80,"wires":[["df89a94e4d84e46f"]]},{"id":"313bde73a6901efc","type":"api-call-service","z":"bc4f7c9d8e2d107c","name":"","server":"778cd90d.9f3698","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":["cb66632e16537223769565331fa2d72e","19c3f13a3371f964cde8ed4b879d41a0","0181da74ad241443987364c638dbc25b","2a1666afb092f53b409818012c272f20"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":430,"y":80,"wires":[[]]},{"id":"df89a94e4d84e46f","type":"switch","z":"bc4f7c9d8e2d107c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","outputs":2,"x":270,"y":80,"wires":[["313bde73a6901efc"],["9cca858025e0acbe"]]},{"id":"9cca858025e0acbe","type":"delay","z":"bc4f7c9d8e2d107c","name":"","pauseType":"delay","timeout":"20","timeoutUnits":"seconds","rate":"1","nbRateUnits":"30","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":420,"y":140,"wires":[["b84e258f25a9d20d"]]},{"id":"b84e258f25a9d20d","type":"api-call-service","z":"bc4f7c9d8e2d107c","name":"","server":"778cd90d.9f3698","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":["cb66632e16537223769565331fa2d72e","19c3f13a3371f964cde8ed4b879d41a0","0181da74ad241443987364c638dbc25b","2a1666afb092f53b409818012c272f20"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":570,"y":140,"wires":[[]]},{"id":"778cd90d.9f3698","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":true,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"","statusHourCycle":"h23","statusTimeFormat":"h:m:s","enableGlobalContextStore":true}]

Captura de ecrã 2023-11-30 141643

Try this example (example 2):

1 Like

If the motion sensor goes off and back on, it will not stop the delay node and the turn off service will still be called. When the sensor turns on, you need to send a value in msg.reset to the delay node. Or, in the events: state node, put if state is off for 20 seconds, then use the top output for light off and the bottom for light on. Then remove the delay and switch nodes.

Example 2 WORKS.

Thanks a lot.

Best

Sorry to jump into this thread . I am experiencing something similar
I have i PIR Node turning on lights in my office and i would like to use the presence/mmwave sensor to trigger the the light off when the sensor is “clear”
Essentially i am using a current status node to confirm the status of the presence sensor.

In your example above you have your sensors triggering the light on and after a delay turn the light off

I have the i same layout for all my lights using motion detection and this is fine how would i go from a light on to turning the light off when presence is clear.

At the moment it seems to me that i need something between my current status node to activate the turn light off

May i please ask you to provide me with some guidance thank you

After the light is triggered on (the state changes to on), use a wait node to detect when the sensor clears.

This is what works for me:
image

[{"id":"97e6a3ea.2d8cd","type":"api-call-service","z":"fe1a8042.af255","name":"Garage Light On","server":"f3f422ce.9f2a6","version":7,"debugenabled":false,"action":"switch.turn_on","floorId":[],"areaId":[],"deviceId":[],"entityId":["switch.garagelightswitch_2"],"labelId":[],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"switch","service":"turn_on","x":310,"y":191,"wires":[["4e0859a3.102238"]]},{"id":"4ff57502.55030c","type":"api-call-service","z":"fe1a8042.af255","name":"Garage Light Off","server":"f3f422ce.9f2a6","version":7,"debugenabled":false,"action":"switch.turn_off","floorId":[],"areaId":[],"deviceId":[],"entityId":["switch.garagelightswitch_2"],"labelId":[],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"switch","service":"turn_off","x":519,"y":248,"wires":[[]]},{"id":"a1f8653c.15a248","type":"trigger-state","z":"fe1a8042.af255","name":"Garage Motion","server":"f3f422ce.9f2a6","version":5,"inputs":0,"outputs":2,"exposeAsEntityConfig":"","entities":{"entity":["binary_sensor.garage_motion_motion"],"substring":[],"regex":[]},"debugEnabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"targetType":"entity_id","targetValue":"switch.garagelightswitch_2","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"customOutputs":[],"outputInitially":false,"stateType":"str","enableInput":false,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":102,"y":191,"wires":[["97e6a3ea.2d8cd"],[]]},{"id":"4e0859a3.102238","type":"ha-wait-until","z":"fe1a8042.af255","name":"No Motion","server":"f3f422ce.9f2a6","version":3,"outputs":1,"entities":{"entity":["binary_sensor.garage_motion_motion"],"substring":[],"regex":[]},"property":"state","comparator":"is","value":"off","valueType":"str","timeout":"0","timeoutType":"num","timeoutUnits":"minutes","checkCurrentState":true,"blockInputOverrides":true,"outputProperties":[],"x":290,"y":249,"wires":[["4ff57502.55030c"]]},{"id":"f3f422ce.9f2a6","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}]

Problem Solved by creating an automation to turn on the lights based on pir and creating a second based on presence detection to turn off the light .

I was trying to only have 1 automation doing it all at the end this was a case of trying to overcomplicate things. use KISS