Note: This is generated from a transcript from one of my YouTube videos


Introduction to Advanced Triggers

Are your automations feeling a little predictable? You’ve likely got a motion sensor set up so that when you walk into a room, it turns a light on. Well, in this video, I’m going to cover seven different triggers that I’ve discovered over the last few years while building out my home automation system. These are my seven favorites. If you’ve got some, leave some in the comments; I’d love to hear them. Let’s get straight into it.

Contact Sensors and Duration Triggers

Contact Sensors and Duration Triggers demonstration at 46.0s Contact Sensors and Duration Triggers demonstration at 54.0s Contact Sensors and Duration Triggers demonstration at 80.0s
The first trigger category involves contact sensors and durations. I have a couple of these automations set up. The first one is for the freezer being left open for too long. We have a contact sensor on our chest freezer, and if the door is open for an extended period, it sends a notification to my wife and me. It also announces around the house, 'Hey, you've left the freezer open. Did you mean to do this?' I've applied this same concept to other automations, but in the inverse. For instance, if there's been motion in the office and the contact sensor has been closed for 45 minutes, it nudges me to stand up. When this automation activates, I get a notification on my Altrix clock on my desk, and some lights change to give me a visual cue that I need to stand up. Then, when I stand up, I get another notification confirming I've done so. Both of these automations are featured in my contact sensors video, so if you like the sound of them, go check that out for more ideas.

Location-Based Triggers

Location-Based Triggers demonstration at 117.0s The next category of triggers is location-based. I have something set up so that if I'm in a particular zone, it triggers an action. In this case, if I'm in the 'gym' zone, which means I'm training and about to shower, it boosts the hot water. This works by detecting if I've been in that zone for 30 minutes. It then hooks into the 'hvac' integration and invokes the boost function for the hot water. I also used a similar concept when I was in the 'school' zone to disable notifications about potty reminders for my son. This was effective because if it knew I was in that zone, I likely wanted to avoid interruptions, especially at certain times.

NFC Tag Triggers

NFC Tag Triggers demonstration at 149.0s NFC Tag Triggers demonstration at 167.0s
The next category of trigger is one that I think is already known to be underrated: NFC tags. They are incredibly cheap and convenient, weatherproof, and can be stuck anywhere. I have one set up to open the garage; I just pull out my phone, tap it on the NFC tag, and the garage opens. In the bathroom, we have an NFC tag that, when tapped with my phone, starts playing a toothbrush song. This sounds strange, but it's very useful for the kids. The toothbrush song is a two-minute track, allowing the kids to brush their teeth along with it, essentially acting as a glorified timer. The way I've set this up is through Tasker, which randomizes the song each time. The trigger is always the NFC tag; I place my phone on it, and it plays one of a few different songs to keep the kids engaged and prevent boredom.

Mac Camera Status Triggers

Mac Camera Status Triggers demonstration at 208.0s Mac Camera Status Triggers demonstration at 232.0s
The next category of trigger is exposed by having one of the companion apps on your Mac. I have both a work Mac and a personal Mac, and I've installed the Home Assistant companion app on both. This app exposes a variety of sensors. One sensor I'm using is the camera sensor. I have a trigger based on whether the camera on my Mac is on or off. If the camera is off, my 'off-camera' lighting setup is active. This setup doesn't look great on camera because the light source isn't ideal. As soon as the camera turns on, it activates an Elgato Key Light, turns off a couple of other lights, and turns on the fancy light behind me. This entire trigger is based on the camera's on/off status. When the camera turns off again, it reverts to my regular lighting setup, which is actually more comfortable for my eyes, as it includes lights behind my monitor.

Object Detection Triggers with Frigate

Object Detection Triggers with Frigate demonstration at 278.0s Object Detection Triggers with Frigate demonstration at 286.0s
This next category of trigger is still related to cameras, but it operates completely differently. Instead of hooking into a camera turning on or off, it's looking at object detection. I have Frigate running, with several cameras feeding into it, including the front and back doorbell cameras, and the main front door camera. If a cat is detected on the front doorbell or front door camera, it turns on a Sonoff water valve and activates a sprinkler. This might sound harsh, and I don't dislike cats, but we had an issue with cats using our garden as a litter tray. This is simply a deterrent to keep them out. Another automation using this object detection is turning on the hallway dashboard. If someone approaches the front door, it preemptively turns on the dashboard because it displays a camera stream. This gives the dashboard a bit more time to 'warm up' and also allows you to see who's at the door on the tablet as you come downstairs. The Filly Kiosk integration also has a feature that detects if a person is present, preventing the dashboard from turning off if someone is in front of it. If you're interested in my dashboard setup, I've made a dedicated video on that.

Sunset, Sunrise, and Time-Based Maintenance Triggers

Sunset, Sunrise, and Time-Based Maintenance Triggers demonstration at 358.0s An example of a trigger that might seem more obvious, but you might still like to explore, is sunset and sunrise. In our conservatory, we have lights that we want to turn on in the evening. Rather than setting a fixed time, like 6 PM, we turn them on at sunset. We also have lights in our conservatory that can be shaped on a magnetic blackboard, allowing us to create any design we want. For example, around Christmas, we turn them into festive shapes like a Christmas tree or a snowman, and change the lights to red, green, and white. I have an automation set up so that if the air conditioning hasn't been used in 72 hours, it runs a quick 20-minute cycle, just turning the fans on to circulate air before shutting down again. Throughout the winter, this automation runs every 72 hours to perform maintenance on the air conditioning. The key here is that it's not a fixed time-based automation; instead, it waits for a duration to elapse before triggering. This is quite a different trigger.

Scheduled Maintenance and Power Monitoring Triggers

Scheduled Maintenance and Power Monitoring Triggers demonstration at 413.0s Scheduled Maintenance and Power Monitoring Triggers demonstration at 435.0s
The final automation in this category is for something that should have happened by a particular time. Our bearded dragon lives in a vivarium in the living room, which has a heat lamp. She needs 40 degrees Celsius to be comfortable throughout the day, as they are cold-blooded and require that heat. Based on our routine, we know that by 8 AM, the temperature in the vivarium should have reached 30 degrees Celsius as it starts to ramp up. We don't typically perform maintenance around that time, so we can set an automation: if it's 8 AM and the temperature is not 30 degrees Celsius, it means the heat lamp probably isn't performing correctly, and we should be notified to check it. The last category of triggers for automations is quite interesting and fun, and one that people might not use or even know exists: monitoring power draw from smart plugs. I have dehumidifiers set up in several rooms to manage humidity levels. I've ensured that if the power drawn by the smart plug connected to a dehumidifier drops, and the humidity level is high, it likely means the dehumidifier needs emptying. If these conditions are met, it sends a notification to my wife and me and announces around the home that the dehumidifier in that room needs attention. If any of these trigger categories particularly grabbed your interest, I'll be creating a blog post to accompany this video, including all the YAML from the automations I've mentioned. There's a lot more content like this coming, so be sure to subscribe if you're interested. I hope you enjoyed it, and I'll catch you in the next one.

Links:

Video

You can watch the full video on YouTube here:

Automations

Freezer open

alias: Notifications - Freezer left open
triggers:
  - type: opened
    device_id: f03ad2c7317d85c5bb34cbb49d7dab92
    entity_id: a8416ee9f8c01ffab30b7b32943eb76f
    domain: binary_sensor
    for:
      hours: 0
      minutes: 15
      seconds: 0
    trigger: device
conditions: []
actions:
  - data:
      message: freezer open!
      title: freezer is open!
    action: notify.mobile_app_pixel_9_pro
  - data:
      entity_id: media_player.kitchen
      message: Oh no! It looks like the freezer might be open
    action: tts.cloud_say
mode: single

Stand up

alias: Notifications - Sitting for too long
triggers:
  - type: not_opened
    device_id: 2df59b838cba31ee9782854af81fa931
    entity_id: 86f8a1a25fb706145b46b09c00cbee95
    domain: binary_sensor
    for:
      hours: 0
      minutes: 45
      seconds: 0
    trigger: device
  - type: occupied
    device_id: a0b642e80f6cc9eac5ba3e89af59ddf6
    entity_id: 09b1c62f3b18c6fb0647889f94c642b4
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 45
      seconds: 0
conditions:
  - condition: and
    conditions:
      - type: is_occupied
        condition: device
        device_id: a0b642e80f6cc9eac5ba3e89af59ddf6
        entity_id: 09b1c62f3b18c6fb0647889f94c642b4
        domain: binary_sensor
      - type: is_not_open
        condition: device
        device_id: 2df59b838cba31ee9782854af81fa931
        entity_id: 86f8a1a25fb706145b46b09c00cbee95
        domain: binary_sensor
        for:
          hours: 0
          minutes: 50
          seconds: 0
      - type: is_off
        condition: device
        device_id: f4c0909bac37c8c46dc2393a7e9df40c
        entity_id: 57b8a27e489b058b5bab7ebc0ef5bfc7
        domain: binary_sensor
        enabled: false
actions:
  - metadata: {}
    data:
      qos: 0
      retain: false
      topic: awtrix_c02208/notify
      payload: >-
        {  "text":"Get up",  "icon": "49337",  "rainbow": false,  "duration": 10
        }
    action: mqtt.publish
  - action: select.select_option
    metadata: {}
    data:
      option: Rainbow
    target:
      entity_id: select.office_wall_wled_preset
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - action: automation.trigger
    metadata: {}
    data:
      skip_condition: true
    target:
      entity_id: automation.office_light_on
mode: single

Boost hot water

alias: "Temperature - Boost hot water while exercising "
triggers:
  - entity_id:
      - person.ben
    to: BJJ
    for:
      hours: 0
      minutes: 30
      seconds: 0
    enabled: true
    trigger: state
    alias: Ben is training BJJ
  - entity_id:
      - person.lizzie
    to: Climbing
    for:
      hours: 0
      minutes: 15
      seconds: 0
    enabled: true
    trigger: state
    alias: Lizzie is climbing
conditions: []
actions:
  - data:
      entity_id: water_heater.thermostat_1
      time_period: "01:00:00"
      on_off: "on"
    action: hive.boost_hot_water
    alias: Boost the hot water
mode: single

Open garage

alias: NFC - toggle garage door
triggers:
  - trigger: tag
    tag_id: ********-****-****-****-************
conditions: []
actions:
  - action: automation.trigger
    metadata: {}
    data:
      skip_condition: true
    target:
      entity_id: automation.doors_garage
mode: single

On call

alias: Lights - office lights on call
triggers:
  - type: turned_on
    device_id: f4c0909bac37c8c46dc2393a7e9df40c
    entity_id: 57b8a27e489b058b5bab7ebc0ef5bfc7
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 0
      seconds: 4
  - type: turned_on
    device_id: 45c5faa79d6b709e2eb817c190798446
    entity_id: a3e88892eb5d149c9c7165c999922264
    domain: binary_sensor
    trigger: device
conditions:
  - type: is_occupied
    condition: device
    device_id: a0b642e80f6cc9eac5ba3e89af59ddf6
    entity_id: 09b1c62f3b18c6fb0647889f94c642b4
    domain: binary_sensor
actions:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      device_id: 162dd37f58925138984ab65508787813
    enabled: true
  - target:
      entity_id:
        - light.office_ceiling_wled_2
    data:
      brightness: 129
      effect: Solid
      color_temp: 312
    enabled: true
    action: light.turn_on
  - target:
      entity_id:
        - light.office_innr_ceiling_light
    data: {}
    action: light.turn_off
  - metadata: {}
    data:
      option: Aurora
    target:
      entity_id:
        - select.office_picture_frame_wled_preset
    action: select.select_option
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: light.office_wall_wled
  - metadata: {}
    data:
      option: Gradient camera
    target:
      entity_id:
        - select.office_kallax_wled_preset
    action: select.select_option
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: light.elgato_a2utb52211twpv
mode: single

Water the cats

Frigate provides binary sensors for object types - in this case, it’s using a binary sensor for ‘cat’

alias: Maintenance - water cats
triggers:
  - type: occupied
    device_id: 9453eca3b18ed24921ee474d6a417ef7
    entity_id: b784e31b092a070859bba5a8ff8d2627
    domain: binary_sensor
    trigger: device
    enabled: true
  - type: occupied
    device_id: 5ece90f97ce8f5ccae5e618642f01d1a
    entity_id: e204f43b0a4fe1f2927337843693d526
    domain: binary_sensor
    trigger: device
    enabled: true
conditions:
  - condition: template
    value_template: >-
      {{ state_attr('automation.maintenance_water_cats', 'last_triggered') ==
      none or (now() - state_attr('automation.maintenance_water_cats',
      'last_triggered')).total_seconds() > 1800 }}
  - condition: state
    entity_id: input_boolean.front_garden_recent_person
    state: "off"
  - type: is_not_open
    condition: device
    device_id: 0e546256a057750bc79caecedb077bb9
    entity_id: ae8a12324b914b89cd351a031ce3198a
    domain: binary_sensor
  - condition: numeric_state
    entity_id: sensor.pirate_weather_precip_probability
    below: 85
actions:
  - type: turn_on
    device_id: e08748e04df8e572eb31e70760024f1c
    entity_id: 85568e5db507a35d03f7e66ff0dd32cf
    domain: switch
  - action: notify.mobile_app_pixel_9_pro
    metadata: {}
    data:
      title: Watered a cat
      message: The sprinkler was set off at {{ now() }}
    enabled: true
    alias: Notify Ben's phone
mode: single

Sunset conservatory lights

alias: Lights - Conservatory lights on
mode: single
triggers:
  - type: motion
    device_id: 754c7cb6982bda5ed173eab8823560b8
    entity_id: 8e01bd65cfd173523880fce9d20d2daf
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 1
    trigger: device
  - event: sunset
    offset: 0
    trigger: sun
conditions:
  - type: is_motion
    condition: device
    device_id: 754c7cb6982bda5ed173eab8823560b8
    entity_id: 8e01bd65cfd173523880fce9d20d2daf
    domain: binary_sensor
  - condition: or
    conditions:
      - condition: sun
        before: sunrise
      - condition: sun
        after: sunset
actions:
  - target:
      entity_id:
        - switch.conservatory_ledvance_socket_wall_light
    data: {}
    action: switch.turn_on
  - data:
      brightness_pct: 100
    target:
      device_id:
        - 5221b2898daad97f4bb40be7be219425
        - e0dc7ab8a4e73f492990b7b738bbc311
    action: light.turn_on

Heat lamp might be out

alias: Temperature - Cheeto's heat lamp
triggers:
  - trigger: time
    at: "08:00:00"
conditions:
  - type: is_temperature
    condition: device
    device_id: a60fb50d05aa2fc0568fa22313e78a87
    entity_id: eac6c6b269b339c37df507381c683b15
    domain: sensor
    below: 30
actions:
  - data:
      title: "Cheeto's viv temperature "
      message: It's colder than it should be in her vivarium. Check the heat lamp!
    action: notify.mobile_app_pixel_9_pro
      entity_id: media_player.living_room_speaker
      message: Cheeto's vivarium is a bit cold. Check the heat lamp.
    action: tts.cloud_say
  - data:
mode: single

Dehumidifier example

alias: Humidity - notify high in snug
triggers:
  - type: power
    device_id: d723b8d78f7a359fe9e92be374014ffe
    entity_id: 569bbd3a09d8e65da55b3fd584a52fe8
    domain: sensor
    trigger: device
    below: 2
    for:
      hours: 1
      minutes: 0
      seconds: 0
  - trigger: numeric_state
    entity_id:
      - sensor.snug_aqara_temperature_humidity
    above: 65
conditions:
  - condition: and
    conditions:
      - type: is_power
        condition: device
        device_id: d723b8d78f7a359fe9e92be374014ffe
        entity_id: 569bbd3a09d8e65da55b3fd584a52fe8
        domain: sensor
        below: 5
      - condition: device
        type: is_on
        device_id: d723b8d78f7a359fe9e92be374014ffe
        entity_id: 81c5a5dbc8af48befb98754130cbe5d6
        domain: switch
      - condition: numeric_state
        entity_id: sensor.snug_aqara_temperature_humidity
        above: 60
actions:
  - device_id: 6fc2c52666a788dca9568baf28521a0d
    domain: mobile_app
    type: notify
    message: Humidity in the snug is high, maybe the dehumidifier is off?
    title: High humidity in snug
  - if:
      - condition: time
        after: "08:00:00"
        before: "19:00:00"
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
          - sat
          - sun
    then:
      - data:
          entity_id: media_player.living_room_speaker
          message: The snug dehumidifier needs emptying
          cache: false
        action: tts.cloud_say
mode: single

Support me to keep making videos

Ko-Fi

If you like the work I’m doing, please drop a like on the video, or consider subscribing to the channel.

In case you’re in a particularly generous mood, you can fund my next cup of coffee over on Ko-Fi

The links from some of my videos are affiliate links, which means I get a small kickback at no extra cost to you. It just means that the affiliate knows the traffic came from me.

×