I have a bunch of presence and motion sensors (like four, but shush) and when people leave rooms I would like to turn the lights off after five minutes, however if someone returns to the room before that five minutes is up, I’d like to start that countdown again. Is there a grateful way to do this that isn’t me just doing if no activity for five minutes, turn off the lights, else wait five minutes and then turn off the lights. Because that’s ugly, rigid and not very smart at all.

  • SolidGrue@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    5 months ago

    You should be able to handle this in HA within a single automation:

    Trigger: Room is occupied (occupancy > 0)
    Condition: Light off
    Action:

    • Call service: Turn Light On
    • Wait for Trigger: Room is clear for 5 minutes (occupancy < 1)
    • Call service: Turn Light Off

    If you are basing your occupancy on more than one sensor state, you could build a helper to combine the states into a single sensor value, which itself might need a Hysteresis helper.

    I’ve started moving some of my own automations over to this method. It works pretty well, but it is susceptible to being interrupted by restarts or reboots. You may need to build in additional logic to reset things to a known state on startup.