Why The Heck cant i turn on things for a cetain time

Hi,

So I have sensons for motion detection, now i have to create an automation for turning it on and off with al loth of checks, because some ligths have 2 sensors for keeping them on, so it would be much easier to just turn a light on for a time:

  action:
    service: light.turn_on
    entity_id: group.living_room_lights
    for:
    for:
      hours: 1
      minutes: 15
      seconds: 0

And the next action just resets the timer, and after the time has passed, it will turn off. Ow, and a normal turn on action will just completely stop the timer.

What do you think about this?

And what if it gets controlled externally?

The problem is that everybody has different ideas on how they want to deal with all the different things that can happen.

With the new script restart run mode, you can easily do this.

turn on, wait 1 hour, turn off.

If the script is started in between, it will just turn on and reset the timer.

You could add a condition before turning it off to see if the context of the light is still the one of the script, so that you know it was the script that turned it on.

4 Likes