Motion sensor light

Hello, I'm just starting to learn Node-Red, I have a zigbee motion sensor and a zigbee light switch, I want to do this:

  1. when motion was detected, the light turned on, the motion disappeared, the light turned off after a certain time, but if motion was detected again at this time, the countdown was reset until the motion completely disappeared and then only turned off after a specified period of time
  2. but if the light is turned on manually using a switch, then it should not turn off according to the diagram in point 1.
    I managed to do the first option, but I can’t figure out how to implement the second, all attempts end up in some kind of wrong loop, please help.

[{"id":"05965022c18821fb","type":"tab","label":"Площадка","disabled":false,"info":"","env":[]},{"id":"2edd61d83a05ca74","type":"server-state-changed","z":"05965022c18821fb","name":"motion_plochadka","server":"10cea322.6322ad","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"binary_sensor.ploshadka","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"on","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":false,"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":90,"y":120,"wires":[["944e86233048e911"],["944e86233048e911"]]},{"id":"944e86233048e911","type":"switch","z":"05965022c18821fb","name":"on and 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":280,"y":120,"wires":[["884b8102ccd0346e","2a45a3bc07f63482"],["86c21caeb5621e4d"]]},{"id":"884b8102ccd0346e","type":"api-current-state","z":"05965022c18821fb","name":"light_ploshadka","server":"10cea322.6322ad","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.ploshchadka","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":460,"y":80,"wires":[["b92a794b9e2bb7e7"],[]]},{"id":"b92a794b9e2bb7e7","type":"api-call-service","z":"05965022c18821fb","name":"On","server":"10cea322.6322ad","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.ploshchadka"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":650,"y":80,"wires":[[]]},{"id":"cffc96e58c6f5e9b","type":"trigger","z":"05965022c18821fb","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"10","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":630,"y":200,"wires":[["d499594ac25118f7"]]},{"id":"d499594ac25118f7","type":"api-call-service","z":"05965022c18821fb","name":"Off","server":"10cea322.6322ad","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.ploshchadka"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":490,"y":280,"wires":[[]]},{"id":"86c21caeb5621e4d","type":"time-range-switch","z":"05965022c18821fb","name":"","lat":"","lon":"","startTime":"07:00","endTime":"17:00","startOffset":"0","endOffset":0,"x":390,"y":200,"wires":[["cffc96e58c6f5e9b"],[]]},{"id":"2a45a3bc07f63482","type":"change","z":"05965022c18821fb","name":"Stop","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":140,"wires":[["cffc96e58c6f5e9b"]]},{"id":"10cea322.6322ad","type":"server","name":"Home Assistant","addon":true}]

It looks like you are using Home Assistant. Not many people on this forum use it so you might want to ask about this on the Home Assistant forum.

1 Like