Nightly Automation

Good afternoon everyone. New to the community and new to Home Assistant. If i do not provide enough information i apologize and will update with anything needed. I have been using smartthings for years now. I decided to take the plunge and switch to Home Assistant and so far i absolutely love it. I completely removed my smartthings hub and moved everything over to HA. In smartthings I had an “automation” that when i asked Alexa to turn on goodnight house the following events happened.

all lights outside of the bedroom turned off
front door locked (schlage lock)
garage door was put down (Chamberlain MyQ)
set living room fan to 50% (GE Fan Switch/Controller
2 lamps in the bedroom turned on to 20% (LifeX bulbs) for 20 minutes then turned off
TV in master bedroom turned on (through Logitech Harmony Hub) for 2 hours then turned off

All of the devices mentioned above have been moved over to HA and function individually just fine. My question is around re-creating the routine in HA. I know many of you will suggest using scripts but to be honest i am not there yet. I have some learning to do. So, would all of the above be possible with a single automation or should i create multiple automations that trigger from a boolean switch? I guess the alternative would be to create one automation to turn off all of the lights, lock the door and put the garage down. Create a second automation to turn on the bedroom lamps with a 20 minute delay then turn them off. Create a 3rd automation to turn on the tv with a 2 hour delay to turn it off.

Any suggestions would be greatly appreciated!

All of that is easily doable with a single automation. Particularly if you put all the lights except your bedroom lights in a group. You just call each command in sequence.

However as your “trigger” is a voice command an automation is not the best fit. A script is. A script is just a list of commands like an automation but without a without a trigger.
e.g.

script:
  goodnight_house:
    alias: Goodnight House
    sequence:
      - service: light.turn_off
        entity_id: group.all_but_bedroom_lights
      - service: lock.lock
        entity_id: lock.front_door
      - service: fan.set_speed
        data:
          entity_id: fan.living_room
          speed: low
      - service: light.turn_on
        data:
          entity_id: group.bedroom_lamps
          brightness_pct: 20
      - service: switch.turn_on
        entity_id: switch.bedroom_tv

Edit: I missed the garage but you get the idea. Just look up the service to close a cover to add it.

Thank you so much for the response. I will be working on scripts next to simplify everything. I am just trying to get it up and running to test more than anything. What i did for the voice part is i created a boolean toggle and exposed that to Alexa. I have tested that part with a single light to turn the boolean toggle on and off and it works perfect. I am curious as to why you say the voice trigger is not the ideal way to do this.

I don’t have a voice assistant but I’m pretty sure you can start the script by setting an alias. You just say “Alexa goodnight house”. No extra messing about with input booleans to trigger an automation.

Just to add to what @tom_l has said…

I, too, came to HA from ST, in which I used webCoRE extensively. That was about two years ago, and I found myself constantly working around bugs in webCoRE. After moving to HA I never l looked back. :slightly_smiling_face:

Regaring the times in your scenario, that’s easy to do by extending your script using delays. E.g.:

      ...
      - service: light.turn_on
        data:
          entity_id: group.bedroom_lamps
          brightness_pct: 20
      - service: switch.turn_on
        entity_id: switch.bedroom_tv
      - delay: '00:20:00'
      - service: light.turn_off
        entity_id: group.bedroom_lamps
      - delay: '01:40:00'
      - service: switch.turn_off
        entity_id: switch.bedroom_tv

Even if you do want to use an automation to monitor the input boolean to decide when to run these commands, it’s probably better to put them in a script and call that script from the automation rather than putting them directly into the automation (for several reasons I won’t go into just now. :wink:)

And welcome to the HA community, BTW!

Great! I will try that as well. I have a lot to learn! Appreciate the help!

@pnbruckner
i am so tired of WebCore! Llike you said, it is so buggy. Half the time it would work. So far HA is faster, more reliable and the UI is amazing!

1 Like

Hopefully this is the last question for the subject. If i want to create a group (lights) would i create the group in the groups.yaml file or in the configuration.yaml file? I a seeing it done both ways. My current configuration.yaml looks like this:

default_config:

Text to speech
tts:

  • platform: google_translate
    group: !include groups.yaml
    automation: !include automations.yaml
    script: !include scripts.yaml
    scene: !include scenes.yaml

When posting YAML code, errors, etc., please try to format them properly. E.g.:

```
YAML CODE
```

There are several ways to organize YAML code. You can put everything into the one configuration.yaml file, !include other files into that one, use packages, or combinations of those. If you’re interested see the corresponding documentation.

But since you already have a configuration layout that includes group definitions from groups.yaml, it probably makes sense to put them there. That assumes you’re using “regular” groups. You might also consider light groups.

1 Like

HA scripts should be discovered by Alexa as soon as they are created and saved as “Scenes”. You can then create a routine in the Alexa app which activates one or more scenes in response to a voice command.