My Top 5 Automations in Home Assistant

Smart homes run on automations. Here are my TOP 5 in Home Assistant and Node-RED

My Top 5 Automations in Home Assistant

Every smart home is automated in some fashion. Over the years, I've built many different automations to make my home smarter or at the very least, to make it do what I need when I need it. In this article, I will cover the automations I use regularly and by that measure, are the most important.

I use both Node-RED as well as the built-in Home Assistant automations. Why use Node-RED if HA has its own automations? In the early days of Home Assistant, most of the configuration for many aspects of that system was done using YAML code. This included automation, thus the reason why I did the more complex things using Node-RED. That wasn't the only reason. I also liked (and still like) the visual aspect of seeing my automations in a "flow". This makes for easier troubleshooting as well as seeing the relationships between the different nodes in an automation. With that out of the way, let's dive into those automations. These are in no particular order. I think they are all equally useful.

Make sure to watch the associated video on this post!

Alarm System Automation

Many things happen based on my alarm status. As of this writing, I am using Alarmo with my z-wave and zigbee sensors.

Automation based on the alarm system state

A number of things are happening here.

If the alarm is disarmed:

  • Turn off the siren. I use an Aeotec Siren 6 for the alarm sounds and other things.
  • Set one of the button lights on my Zooz scene switch to green, indicating the alarm is disarmed.
  • Between 0730 and 2230, if the work mode flag is off, turn on ceiling fans.

If the alarm is set:

  • Set the scene controller button to red on the scene switch.

If the alarm is tripped (pending entry):

  • Set the Siren 6 to play the alarm pending notification sound.

If the alarm is triggered:

  • Turn off the entry delay on the Siren 6 and turn on the alarm triggered sound. (If I don't turn off the playing sound first, it doesn't work correctly.)
  • Use a function node to create a notification for pushover.
  • Send the pushover notification and turn on ALL the lights everywhere.

As I write this, I realize that there are other actions that happen with different alarm states and those are covered under other automations. That's the drawback of a few years of building out my system one piece at a time. Time to make a mental note to clean up and consolidate things.

Entry Door Actions

This is another busy automation that does a number of things based on door opening and unlocking.

Entry Door Automation Flows in Node-RED

If the garage door is opened with a valid code the following happens:

  • Between 0800 and 2100, the smart speakers play a voice announcement that the garage door is open. It it is closed, the closed announcement plays instead.
  • Specific lights in the house are turned on so as not to enter a darkened house. Which lights come on depend on the time of day. During the day, I don't need them all on, for example.
  • The scene controller sets a button to red indicating the garage door is open.
  • A pushover alert is sent as a notification of open or close status.
  • The atom matrix and ultrasonic sensor get turned on for five minutes to allow parking the car in the correct spot (see my video on that project).
  • The alarm system is disarmed.
  • During the holidays, the Christmas tree lights get turned on so they are all lit up when we enter. I turn them off with the alarm arming when we leave. Safety and all.

If a proper code is entered on the door locks, most of the same things happen. The difference, of course, is that the Atom and sensor are not turned on and the smart speaker announcements are not played. A pushover notification is sent, though, alerting that a code was entered into a door lock.

Light Automations (non-motion)

This flow is used to turn on lights based on the time of day for security, safety, and aesthetics.

Non-Motion light automations in Node-RED

This is a simple automation and does the following:

  • Between sunset and sunrise, the primary room lamps, living room lamps, and game room lamps all turn on. (There is a script that turns them off at bedtime when the alarm is armed).
  • Between sunset and sunrise, the outside lights come on.
  • At midnight, the study and LR lamp are turned off in case someone was in those rooms and bypassed the night mode.

You might notice I have two "Sunset to Sunrise" nodes turning lights on. The difference is the offset for those. I want the lights inside to come on a bit earlier than the outside lights. There are other ways to do this, of course, but I chose this route.

Frigate NVR Alerts

I run a Frigate NVR that ties into Home Assistant and I use the automations in HA to drive notifications with images to my mobile device.

This is the view of the automation UI. However, it's hard to see what is happening so I'll include the code below the image as well.

Frigate automation that shows alerts and provides images

Here is the YAML version of the above:

alias: Frigate Driveway w Image
description: ""
  - platform: mqtt
    topic: frigate/events
    payload: driveway/new
    value_template: "{{ value_json['after']['camera'] }}/{{ value_json['type']}}"
    id: frigate-event
condition: []
  - choose:
      - alias: Frigate Event
          - condition: trigger
            id: frigate-event
          - condition: template
            value_template: >-
              {{ not this.attributes.last_triggered or (now() -
              this.attributes.last_triggered).seconds > cooldown }}
          - variables:
              id: "{{ trigger.payload_json['after']['id'] }}"
              initial_entered_zones: "{{ trigger.payload_json['after']['entered_zones'] }}"
          - alias: Notifications enabled for object label
            condition: template
            value_template: "{{ not labels|length or object in labels }}"
          - alias: Notify on new object
              - conditions:
                  - condition: template
                    value_template: "{{ not zone_only or initial_entered_zones|length > 0 }}"
                  - condition: template
                    value_template: >-
                      {{ not zones|length or zones|select('in',
                      initial_entered_zones)|list|length > 0 }}
                  - service: notify.{mobile device}
                      message: Person on Driveway
                      title: Driveway Alert
                        image: "{{base_url}}/{{id}}/thumbnail.jpg?format=android"
                        clickAction: "{{action_url}}/api/events/{{id}}/clip.mp4"
                          - action: URI
                            title: View Clip
                            uri: "{{action_url}}/api/events/{{id}}/clip.mp4"
                        channel: drive_cam
                        priority: high
                        ttl: 0
                  - service: notify.{my pc}
                      message: Person on Driveway
                      title: Driveway Alert
                        image: "{{base_url}}/{{id}}/thumbnail.jpg"
mode: single
  base_url: >-
  action_url: https://{my local proxy url}
  cooldown: 90
    - driveway_whole_area

This seems complicated, but it isn't really. The automation is listening for MQTT events from frigate. In this case, from the driveway/new topic. When it sees that event, it will check a few things:

  • Are we NOT in a cooldown period? I use 90 seconds not to flood alerts when activity is constant.
  • Is the activity within a zone that we have specified? In this case, I look at zone "driveway_whole_area".

If both of the above are satisfied, send an actionable alert to both my mobile phone and my main PC, running Hass Agent. In that notification, include the snapshot associated with the event as well as a link to view the associated video clip.

I use this same automation with all my cameras, changing the MQTT topic to match the camera name and, if applicable, the cooldown period.

Lightning Alerts

Automations don't have to be complicated. This is a very useful, but very simple, automation.

description: ""
  - platform: numeric_state
    entity_id: sensor.blitzortung_lightning_counter
    above: "3"
condition: []
  - service: notify.pushover
      message: Lightning In the Area
      title: Lightning Detected
        sound: thunder
mode: single

What it does:

If the lightning sensor detects more than 3 lightning strikes, it will send a pushover notification to my mobile phone. To make it more exciting, tt uses the "thunder" sound, which is a custom sound I added to Pushover.

The blitzortung integration provides the lightning sensor for this automation and is configurable. Currently, those 3 strikes have to be within 15 miles (24km) during the past 30 minutes. That's close enough to give me a warning that something might be approaching.

I also have another exact automation but instead sets the "above" value to 251. That tells me that something potentially severe is nearby. It is quite possible to combine the two into the same automation using conditions, but I opted to keep it simple in this case.

Honorable Mention (Thermostat and Fans)

This one isn't in the top 5, but it is definitely important from a WAF perspective.

Automation in Node-RED showing thermostat and fans

What it does:

-- PATH 1 --

  • At 2:30 pm, if the outside temperature is >= 98F AND the vacation mode is not set AND the work mode status is ON, set Ecobee to "Home" mode and turn on the ceiling fans. Notify me via pushover that Ecobee is set to Home.

-- PATH 2 --

  • At 2:30 pm, if the outside temperature is >= 98F AND the vacation mode is not set AND the alarm mode is either armed_away or armed_home, set the Ecobee to "Home" mode. Notify me via pushover that Ecobee is set to Home.

This one probably takes some explanation. Since I work from home, I have a script I call during my workday that sets a number of items to certain states. For example, ceiling fans off, thermostat to 98F, etc. In order for the house to cool down to WAF-acceptable levels, I want to make sure I turn the fans on and set the thermostat to 73F. I have figured out, via the Ecobee beestat site, how much time I need to cool the house down x degrees. If the temp is >= 98F I need to start cooling at 2:30. Otherwise, that 30-minute countdown kicks in and everything fires off at 3 pm instead.

I have many more automations but the ones above are used daily and in some cases multiple times per day. I hope that it gives you some ideas for your own automations.

Don't forget to watch the video for this blog and thanks for reading!