Always surprises me when I go to do something in HA and realize that I can’t figure out how.

This time its lights, specifically making sure that they don’t get left on.

Until now I’ve simply been creating an automation for each light switch so that if it changes state from Off to On and when it’s 30 minutes after sunrise it’s starts a 15 minute wait and then changes the state of the switch to off.

This approach mostly works but it’s less than ideal.

First I’m having to create an automation for each device. How do I do it by Area, or list / group of devices, instead?

Second if a device is turned on too early there’s no state change for the automation to catch and it never fires. I could fix this by creating another automation that checks for it but then I’ll have even more of them to manage.

Third this doesn’t work very well if you want different things to happen on the weekends as opposed to during the weekday. For instance on a Saturday I may WANT that closet light to stay on longer because I’m putting away clothes.

It’d be really nice if I could program HA like this ‘On a weekday if you see any device on this list turn on 30 minutes after Sunrise I want you to turn whichever one(s) it was off again 15 minutes later.’.

I’m must be missing something here because surely HA can do this, right?

  • comradegreetingcard@lemmy.ml
    link
    fedilink
    English
    arrow-up
    14
    ·
    edit-2
    10 months ago

    So, you don’t need an automation per entity. You can add additional entities to the trigger seen here (you can add groups too, kitchenlights is a group of 4 lights):

    As circled above, you can also set a “for” time, in this case when the light is on for 15 min.

    The time condition has the option for a day off the week. Just leave the time portion blank.

    To keep this all in one automation, skip the condition section and go to the action section.

    Use the choose block and set the conditions under an option

    The action will be a template

    service: light.turn_off target: entity_id: “{{ trigger.entity_id }}” data: {}

    Edit formatting

    • Buelldozer@lemmy.todayOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      10 months ago

      Wow, this is one of the most thorough answers I’ve ever seen on any HA forum! Thank you!