Setting up flow for triggering lights when motion detected

I'm working on a flow that triggers a light when motion is detected, I got everything working except the most important part, when continuous motion is detected, the light still goes out, and later on when detecting motion again even if I never left the room or desk.

Play with this using an inject to simulate motion. Once happy, adjust the time as required & connect to your motion detector & light ...

[{"id":"7ddf9ea.ce1666","type":"trigger","z":"f2981eab.77c68","name":"","op1":"1","op2":"0","op1type":"num","op2type":"num","duration":"5","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":440,"y":1200,"wires":[["a10c8787.6bcde8"]]},{"id":"4f9f0445.d36d2c","type":"inject","z":"f2981eab.77c68","name":"motion","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":290,"y":1200,"wires":[["7ddf9ea.ce1666"]]},{"id":"a10c8787.6bcde8","type":"switch","z":"f2981eab.77c68","name":"payload == 1 or 0","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":1200,"wires":[["d0e34d98.f2042","9cd45d14.c50fc"],["4666b91c.95c868","9cd45d14.c50fc"]]},{"id":"d0e34d98.f2042","type":"debug","z":"f2981eab.77c68","name":"Switch on","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":760,"y":1140,"wires":[]},{"id":"4666b91c.95c868","type":"debug","z":"f2981eab.77c68","name":"Switch off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":760,"y":1260,"wires":[]},{"id":"9cd45d14.c50fc","type":"debug","z":"f2981eab.77c68","name":"The Lamp","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":900,"y":1200,"wires":[]}]
1 Like

that is exactly what my demo flow does. Did you try it?

Not yet, do you mean that repressing the inject node simulates the timer resetting?New to node-red, and haven't figured everything out yet.

It does what you asked.

Pressing the inject simulates the motion detection (I dont have your motion sensor so had to use something to "fake it"!)

The debug nodes show you the what is happening (so you can understand if it is working) - again, I dont have your Light so had to use something to demonstrate that it actually does what you asked!!!

In short - just give it a go.



TIPS (as you are new to node red)

To import a flow

  • Press CTRL+I (or click the hamburger menu → click 'import')
  • Paste the copied JSON flow
  • Deploy

Recommended learning

  • I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

I will tonight when the kids are asleep, I already figured out importing, and that worked great, thanks a lot!But as soon as I'm trying to "convert" everything to on or off state for the motion sensor and what the triggers are supposed to send etc. I'm stuck scratching my head again.

i just figured out how to export, thats progress as well, i changed to string instead off numbers, and after a while when entering the room, it sure triggered the light, im starting to think that this is in fact an hardware issue, and that the aqara motion detectors im using is "checking" for motion to rarely, but it SHOULD do it within ten minutes.

now the light turned on, but never reset the timer within 10 minutes, cant find anything more than a hack for the device to shorten the interval.

[{"id":"7ddf9ea.ce1666","type":"trigger","z":"24269c25.228774","name":"","op1":"on","op2":"off","op1type":"str","op2type":"str","duration":"10","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":250,"y":740,"wires":[["a10c8787.6bcde8"]]},{"id":"a10c8787.6bcde8","type":"switch","z":"24269c25.228774","name":"payload == 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":460,"y":740,"wires":[["e67943e9.77dad"],["b5b6f123.8ccab"]]},{"id":"d0e34d98.f2042","type":"debug","z":"24269c25.228774","name":"Switch on","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":680,"wires":[]},{"id":"4666b91c.95c868","type":"debug","z":"24269c25.228774","name":"Switch off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":800,"wires":[]},{"id":"903787f5.d27818","type":"server-state-changed","z":"24269c25.228774","name":"Motion","server":"c019f8af.2f6308","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.motion_sensor_study_desk","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,"x":90,"y":740,"wires":[["7ddf9ea.ce1666"],[]]},{"id":"e67943e9.77dad","type":"api-call-service","z":"24269c25.228774","name":"Light on","server":"c019f8af.2f6308","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.study_desk_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":760,"y":680,"wires":[["d0e34d98.f2042"]]},{"id":"b5b6f123.8ccab","type":"api-call-service","z":"24269c25.228774","name":"Light off","server":"c019f8af.2f6308","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.study_desk_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":760,"y":800,"wires":[["4666b91c.95c868"]]},{"id":"c019f8af.2f6308","type":"server","name":"Home Assistant","addon":true}]

Add a debug node showing what is coming out of the motion detection node and see what that is showing. If that is working then show us what it gives. Basically you just need a message which appears every time there is motion, and connect that in instead of the inject node.

Is your motion sensor only sending out a single on message once it detects motion and than only ever sends the next message (off) when there is no motion? I have quite a few motion sensors which work this way as its common for battery powered zigbee/z-wave/enocean motion sensors to act this way.
In that case you would need a slightly different flow to what @Steve-Mcl suggested.
Give me a minute and ill get to my computer and post the one I use for this.

Edit

Here is a simplified version for that scenario:

[{"id":"ddb1db53.5aedc","type":"inject","z":"ba5b6f93.bba11","name":"no motion","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":510,"y":280,"wires":[["8bc22858.70ccd"]]},{"id":"5873d2fb.d39afc","type":"inject","z":"ba5b6f93.bba11","name":"motion","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":500,"y":220,"wires":[["8bc22858.70ccd"]]},{"id":"8bc22858.70ccd","type":"switch","z":"ba5b6f93.bba11","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":690,"y":220,"wires":[["ded175c1.f4ab18","9006e52c.9199d"],["ded175c1.f4ab18"]]},{"id":"ded175c1.f4ab18","type":"trigger","z":"ba5b6f93.bba11","name":"10s no motion","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":880,"y":280,"wires":[["9006e52c.9199d"]]},{"id":"8ed1310d.d15948","type":"debug","z":"ba5b6f93.bba11","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1090,"y":220,"wires":[]},{"id":"9006e52c.9199d","type":"rbe","z":"ba5b6f93.bba11","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":890,"y":220,"wires":[["8ed1310d.d15948"]]}]

Edit 2 first one had one wire wrong :see_no_evil:

Just for explanation, what does be do with the flow, for my understanding.

Its pretty similar to what you had in mind in the first place but as i said this only functions if your motion sensor sends its status as described above, so one on message and than no further message until off.
If you want to adapt it to your flow just change the switch node to switch on the messages your motion sensor sends from ha. You also need to change the reset property in the trigger node to reset on the on message that your motion sensor sends. Start with that and see if you see the expected output on the debug node.
If it works you can than add a switch node instead of the debug that sends the right message to your right home assistant node.
You were on the right track with your flow above just have a close look at how the trigger node is set up in my example and have a good play with it. The rbe node is just there so that no duplicate on messages get send and is not necessary but nice to have.

FWIW:

Here is how I am handling it. I also have my PIR sensor feeding into the Node Red switch in the UI so it properly updates that status icon.

[{"id":"c101bca7.599e8","type":"tab","label":"Lights-Exterior","disabled":false,"info":""},{"id":"eef1c2a2.fa4b9","type":"ui_switch","z":"c101bca7.599e8","name":"","label":"Wall socket #1","tooltip":"Touch on/off","group":"a16b698e.f9b718","order":1,"width":5,"height":2,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"On","onvalueType":"str","onicon":"fa-power-off fa-4x","oncolor":"green","offvalue":"Off","offvalueType":"str","officon":"fa-power-off fa-4x","offcolor":"red","x":967,"y":154,"wires":[["bc22a0ba.d658b"]]},{"id":"bc22a0ba.d658b","type":"switch","z":"c101bca7.599e8","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":1159,"y":154,"wires":[["ac762bfd.9e4b18"],["5b134a97.348054"]],"outputLabels":["On","Off"]},{"id":"ac762bfd.9e4b18","type":"exec","z":"c101bca7.599e8","command":"python3 send.py -p 179 -t 1 1398067","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Wall socket #1 On","x":917,"y":494,"wires":[[],[],[]]},{"id":"5b134a97.348054","type":"exec","z":"c101bca7.599e8","command":"python3 send.py -p 179 -t 1 1398076","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Wall socket #1 Off","x":917,"y":554,"wires":[["ac586221.423cb"],["42dc045c.7dc5bc"],["39e781af.8d397e"]]},{"id":"2348793c.900486","type":"debug","z":"c101bca7.599e8","name":"From sensor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":137,"y":74,"wires":[]},{"id":"85079c52.de7ce","type":"rpi-gpio in","z":"c101bca7.599e8","name":"Motion Detector on pin 32 GPIO12","pin":"32","intype":"tri","debounce":"25","read":false,"x":147,"y":154,"wires":[["2348793c.900486","2ab7247a.cfca5c","499160af.3bc8e"]]},{"id":"2ab7247a.cfca5c","type":"switch","z":"c101bca7.599e8","name":"Motion=0 from PIR to \"On\"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":160,"wires":[["7f4b77a2.77e538","6623a591.49fd6c","b4e71e17.baaee"],[]]},{"id":"7f4b77a2.77e538","type":"trigger","z":"c101bca7.599e8","name":"Keep on for 5 unless re-triggered","op1":"","op2":"Off","op1type":"nul","op2type":"str","duration":"5","extend":true,"overrideDelay":false,"units":"min","reset":"1","bytopic":"all","topic":"topic","outputs":1,"x":780,"y":220,"wires":[["eef1c2a2.fa4b9"]]},{"id":"c364012d.6d8c2","type":"inject","z":"c101bca7.599e8","name":"Send 0 = on","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":117,"y":214,"wires":[["2ab7247a.cfca5c"]]},{"id":"ac586221.423cb","type":"debug","z":"c101bca7.599e8","name":"stdout","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1117,"y":474,"wires":[]},{"id":"42dc045c.7dc5bc","type":"debug","z":"c101bca7.599e8","name":"stderr","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1147,"y":534,"wires":[]},{"id":"39e781af.8d397e","type":"debug","z":"c101bca7.599e8","name":"return code","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1147,"y":594,"wires":[]},{"id":"1ea026a6.1ff3b9","type":"mqtt in","z":"c101bca7.599e8","name":"","topic":"From_Relay_1","qos":"2","datatype":"auto","broker":"98e43eb6.346e2","x":787,"y":34,"wires":[["eef1c2a2.fa4b9"]]},{"id":"5109ac28.9c8bc4","type":"comment","z":"c101bca7.599e8","name":"Outside light(s) with motion sensor","info":"","x":167,"y":28,"wires":[]},{"id":"499160af.3bc8e","type":"ui_statetrail","z":"c101bca7.599e8","group":"869de687.095708","order":1,"width":19,"height":2,"name":"State Trail of Motion detect","label":" Motion Detected Timeline - 24H","states":[{"state":0,"col":"#e63900","t":"num","label":"Motion"},{"state":1,"col":"#45ba62","t":"num","label":"No Motion"}],"periodLimit":"24","periodLimitUnit":"3600","timeformat":"HH:mm","tickmarks":4,"persist":true,"legend":1,"combine":false,"blanklabel":"Waiting Data","x":460,"y":220,"wires":[[]],"inputLabels":["From Motion detect"]},{"id":"6623a591.49fd6c","type":"debug","z":"c101bca7.599e8","name":"From Switch On","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":407,"y":94,"wires":[]},{"id":"b4e71e17.baaee","type":"change","z":"c101bca7.599e8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"On","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":140,"wires":[["eef1c2a2.fa4b9"]]},{"id":"6252f43b.6dc66c","type":"inject","z":"c101bca7.599e8","name":"Send 1 = off","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":117,"y":254,"wires":[["2ab7247a.cfca5c","499160af.3bc8e"]]},{"id":"fcbd9dc4.fcfee","type":"rpi-gpio out","z":"c101bca7.599e8","name":"","pin":"33","set":"","level":"0","freq":"","out":"out","x":390,"y":440,"wires":[]},{"id":"c77ef268.79402","type":"inject","z":"c101bca7.599e8","name":"Send = on","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":100,"y":420,"wires":[["fcbd9dc4.fcfee"]]},{"id":"5c10f2d0.4af06c","type":"inject","z":"c101bca7.599e8","name":"Send  = off","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":100,"y":460,"wires":[["fcbd9dc4.fcfee"]]},{"id":"63bb4098.a6566","type":"comment","z":"c101bca7.599e8","name":"Test to turn on LED","info":"","x":130,"y":360,"wires":[]},{"id":"501e1954.e9a1b8","type":"exec","z":"c101bca7.599e8","command":"python3 send.py -p 360 -t 1 14652577","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Relay #2","x":360,"y":540,"wires":[[],[],[]]},{"id":"61b25d5a.7d8ba4","type":"exec","z":"c101bca7.599e8","command":"python3 send.py -p 360 -t 1 14652580","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Relay #4","x":360,"y":660,"wires":[[],[],[]]},{"id":"c6c3b32.f875d5","type":"inject","z":"c101bca7.599e8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":660,"wires":[["61b25d5a.7d8ba4"]]},{"id":"8119ef26.286b7","type":"exec","z":"c101bca7.599e8","command":"python3 send.py -p 360 -t 1 14652578","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Relay #3","x":360,"y":600,"wires":[[],[],[]]},{"id":"bec0110e.be654","type":"inject","z":"c101bca7.599e8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":540,"wires":[["501e1954.e9a1b8"]]},{"id":"3ecb7d2d.b7dbe2","type":"inject","z":"c101bca7.599e8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":600,"wires":[["8119ef26.286b7"]]},{"id":"a16b698e.f9b718","type":"ui_group","name":"Porch","tab":"d6a000ae.859cc","order":1,"disp":true,"width":"6","collapse":false},{"id":"98e43eb6.346e2","type":"mqtt-broker","name":"P-Pi-Gibson","broker":"192.168.1.101","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"869de687.095708","type":"ui_group","name":"Top Bar","tab":"d6a000ae.859cc","order":4,"disp":false,"width":"19","collapse":false},{"id":"d6a000ae.859cc","type":"ui_tab","name":"Lights-Exterior","icon":"lightbulb_outline","order":3,"disabled":false,"hidden":false}]

i can verify that this setup doesnt work for me, i dont know if i have done anything wrong, but the lights turn on, but from what i can tell there is nothing that tells them to shut of again.

[{"id":"8bc22858.70ccd","type":"switch","z":"24269c25.228774","name":"","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":920,"wires":[["ded175c1.f4ab18","9006e52c.9199d"],["ded175c1.f4ab18"]]},{"id":"ded175c1.f4ab18","type":"trigger","z":"24269c25.228774","name":"10m no motion","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"10","extend":false,"overrideDelay":false,"units":"min","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":470,"y":980,"wires":[["9006e52c.9199d"]]},{"id":"8ed1310d.d15948","type":"debug","z":"24269c25.228774","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":920,"wires":[]},{"id":"9006e52c.9199d","type":"rbe","z":"24269c25.228774","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":480,"y":920,"wires":[["358a424a.622dae"]]},{"id":"457e6964.94f388","type":"server-state-changed","z":"24269c25.228774","name":"Motion detected","server":"c019f8af.2f6308","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.motion_sensor_study_desk","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,"x":100,"y":920,"wires":[["8bc22858.70ccd"],[]]},{"id":"de43eb5c.d41908","type":"server-state-changed","z":"24269c25.228774","name":"Motion not detected","server":"c019f8af.2f6308","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.motion_sensor_study_desk","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","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,"x":110,"y":980,"wires":[["8bc22858.70ccd"],[]]},{"id":"358a424a.622dae","type":"api-call-service","z":"24269c25.228774","name":"Light on","server":"c019f8af.2f6308","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.study_desk_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":700,"y":920,"wires":[["8ed1310d.d15948"]]},{"id":"c019f8af.2f6308","type":"server","name":"Home Assistant","addon":true}]

You never showed us a debug of what messages your pir is sending via home assistant, that would be quite important to know.
As i said above my flow will only work if there is a single motion message on motion and a no motion message when there is no more motion.
@Steve-Mcl s flow will work if there are only motion messages and those are repeated as long as there is motion and no message for no motion, the messages just stop.
So which of those two ways is the one youre pir behaves. Choose the flow above according to that.

bild2

this is what a debug attached straight to my sensor node gives, i feel like there is something wrong, or it is just as simple as you say, i have setup the flow for the wrong kind of motion sensor i use, to me it looks wrong to use the "if true" dot on the "no motion" node, but maybe it isnt.

EDIT, forgot to mention, where is the command to turn of the light if no motion detected?

I can’t test your home assistant nodes as I don’t use ha. But for me simulating on and off it works fine:

[{"id":"8bc22858.70ccd","type":"switch","z":"a7780937.2d47c8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":220,"wires":[["ded175c1.f4ab18","9006e52c.9199d"],["ded175c1.f4ab18"]]},{"id":"ded175c1.f4ab18","type":"trigger","z":"a7780937.2d47c8","name":"10s no motion","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":865,"y":285,"wires":[["9006e52c.9199d"]]},{"id":"8ed1310d.d15948","type":"debug","z":"a7780937.2d47c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1170,"y":220,"wires":[]},{"id":"9006e52c.9199d","type":"rbe","z":"a7780937.2d47c8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":870,"y":220,"wires":[["8ed1310d.d15948"]]},{"id":"3edc93fc.3e408c","type":"inject","z":"a7780937.2d47c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":470,"y":220,"wires":[["8bc22858.70ccd"]]},{"id":"5ee73c37.a0adf4","type":"inject","z":"a7780937.2d47c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":470,"y":300,"wires":[["8bc22858.70ccd"]]}]

So it should definitely work with those payloads. Try it with the shortened interval above and just attach separate debug nodes to every step so that you can follow where it fails.

Edit:

That’s what the trigger node at the bottom does. When it receives an off it waits for the configured period and than sends the off to its output but only if no new on arrives in that period as on resets it so that it never sends anything. You can see that a trigger is running when there is a blue dot below the trigger node. Attach a debug to it in the flow above and watch it.
Are on and off also the commands that the ha output node expects to switch the light? Otherwise you will have to add an additional change node to change those to the correct commands.

Edit 2:
Can you also attach separate debug nodes to motion and no motion to verify that each of them does their job as expected? If you give names to your debug nodes you can easily see in the debug tab which of the debug nodes the message came from.

Edit 3:
Could it be that both your nodes send a message on no motion and that that message is actually on for the bottom node on the no motion event? Because that would explain the off trigger never firing.
image
@pimmen85 Please connect a named debug node to each of the home assistant nodes and show us a debug output of the complete sequence motion detected -> no more motion. Understanding the actual output you get from home assistant will be what we need to get to the bottom of this as only you can provide this.

@JGKK look at the Id of the node in the debug, those on/off messages appear to be coming from the same node.

@pimmen85, my demo will work if you filter out the off messages. I.e. put a switch after the sensor and only permit "on" messages to pass.

Which would mean my flow should still work as this is also the case in my set up. Unleast the no motion home assistant node is sending an on which is what I’m thinking is maybe happening. Which is why I asked for separate debug nodes to be connected.

But only if home assistant repeats the on message while there is still motion otherwise it will always turn off the light after the trigger period even if somebody is still in the room. And I think the aquara zigbee pirs don’t do that. They send on on motion and than only ever the next messages off on no motion after an internal timeout. They do this to save battery power.

Good point. I was thinking of traditional PIR services.

The aquara zigbee ones are especially bad. The only check for motion like every two minutes to save battery and don’t even play nice with a normal zigbee mesh as they do stuff that doesn’t exactly conform to standards.
I gave up on the aquara hardware from China long ago because of the many issues.