Help with motion trigger and reset

I have a light which turns on at dusk and turns off at a specific time of night, this flow works as expected:

I am trying to add an additional flow for the same light to act as a night light:

  • If the light is off, and there is motion, and the ambient light in the room is less than 5 lux - turn the light on
  • After 3 minutes, if there are no more motion events - turn the light off

I am having issues with the new flow, because of the existing timer flow - the light is turning off at unintended times due to no motion in the Living area. I tried including a time range node, but I would rather not use it as it also introduces edge cases.

Is there some way to set a global value when the light is turned on from the new flow and only turn it off if that is the case and there is no motion?

What is the correct node-red way to execute this additional flow without interfering with the existing flow?

Remember that a trigger node can be set to send one message , wait 3 minutes and send a different message.

So send your night light ON message via the trigger node. It sends OFF after 3 minutes if no further movement is detected

And your dusk to 22:30 can be made to send ON every 2.5 minutes between those hours, routed through the same trigger node.

An example using inject and debug nodes rather than your bright blue and green nodes, whatever they are.

[{"id":"1635d0258fe0f082","type":"inject","z":"eb8a7d385ac37efe","name":"At dusk send ON","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":120,"y":440,"wires":[["061be24778af07f1"]]},{"id":"061be24778af07f1","type":"trigger","z":"eb8a7d385ac37efe","name":"","op1":"ON","op2":"0","op1type":"str","op2type":"str","duration":"-150","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":390,"y":440,"wires":[["dfd0e959fd823424"]]},{"id":"cea752d0195976a7","type":"inject","z":"eb8a7d385ac37efe","name":"At 22:27 send msg.reset","props":[{"p":"reset","v":"","vt":"date"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":480,"wires":[["061be24778af07f1"]]},{"id":"dfd0e959fd823424","type":"trigger","z":"eb8a7d385ac37efe","name":"On for 3 min. Extend delay on new msg","op1":"ON","op2":"OFF","op1type":"str","op2type":"str","duration":"3","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":520,"y":520,"wires":[["0c4660db1f31d736"]]},{"id":"7bfc632f7aec76a0","type":"inject","z":"eb8a7d385ac37efe","name":"Motion detection logic","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":140,"y":580,"wires":[["dfd0e959fd823424"]]},{"id":"0c4660db1f31d736","type":"debug","z":"eb8a7d385ac37efe","name":"Switch lamp","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":580,"wires":[]}]

Very Nice and elegant @Jbudd !!

OP - the majority of people on here do not use the Webhook integration for Home Assistant so wil be unable to install and test flows etc that contain nodes from this package.

I would suggest that you may want to ask this on the Node Red Sub forum on the HA forums or put the same flow up with Inject nodes named appropriately to simulate the nodes from HA

regards

Craig

Thanks both, I did not realise those nodes were specific to HA.

I will ask in the other forum with more details as my question was also not appropriately clear - the light is turned on by a smart plug, not controlled by the light itself - so constantly sending an on message with a 'relay click' every 2.5 minutes is not ideal.

If the relay is already on then it will not click.

Obviously it's up to you to decide how appropriate the suggestion was for your setup. Presumably you tried it and your relay does click when multiple "ON" messages arrive.

The light which I turn on like that is also on a smart socket (I just can't see how spending £15 on a lightbulb is "smart")
The socket has Tasmota firmware and it is set to turn off after 15 minutes, even if Node-red or the network goes down.
Node-red sends "ON" every 10 minutes during the evening and never needs to sends "OFF".
My relay does not click each time, all that happens is the time it will turn off shifts further into the future.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.