Turn off lights after time. Turn on same lights when motion is detected

Hello everyone,

first off all I´m new to Home Assistant and also new to Node-RED. So far I love it but sometimes struggle to get things working as I want. Currently I´m trying to start automating my lights.

Here is a quick description of what I want to do:

When in one of my room there is no motion detected for 10 minutes, I want to turn off all the lights in this room. When motion in this room is detected again, I want the lights that were on before to turn on and set to the same state (brightness, etc.). I don´t want to turn on the lights that were off before.

So for example if enter the room an all light were off before, I don´t want to turn on any lights.
Or when one light was on and automatically turned off after 10 minutes, I wan´t only this light to be turned on the next time motion is detected.

I hope everyone understands what I mean :smiley:

What I got working so far is a basic sequence, that turns on one light when motion is detected and turns it off after 10 minutes when no motion was detected.
The problem I have now is when i add more lights, every light would turn on and not only the ones that were on before.

I found a custom component that could maybe help me with this, but couldn´t figure out how to use it. https://github.com/PiotrMachowski/Home-Assistant-custom-components-Saver

How can I archive this with Node-RED?

Thanks in advance for your help!

Create a scene before you turn off the lights and activate to turn them on.

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/cookbook/saving-and-restoring-states.html#using-home-assistant-scene-creation

1 Like

That was exactly what I was looking for. Got it working today! Thanks for the help!