Automating My New Smart Home!

If you just watched the video at this link, thanks so much for supporting the channel!

Here is the code for every automation and script mentioned in the video.

Affiliate Disclosure: This page has affiliate links, which earn us commission at no cost to you.

Annie wants to come inside

Our dog Annie is only 15 pounds, so I wasn’t sure if the TrampleTek Blue pressure sensor mat could detect her under the outside door mat. Turns out, it can! I had to adjust the calibration, but after a minute of dialing it in I haven’t touched it since.

alias: Annie wants to come inside annoucement from pressure sensor
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.ttb_mat_2271a8_mat_sensor
    to:
      - "on"
    for:
      hours: 0
      minutes: 0
      seconds: 4
conditions: []
actions:
  - action: script.speaker_announce_message
    metadata: {}
    data:
      volume: 70
      message: Annie wants to come inside
mode: single

This code just calls a script and passes in two variables. One variable is the message “Annie wants to come inside” and the other is the volume level. I wanted to have different volume levels for different announcements, and it is nice to have that option! But many of the announcements are a similar volume so I wouldn’t say it’s necessary.

Ok, let’s go over the announce script in the next automation.

Less annoying announcements

There are a lot of reasons I might want to announce something on all the speakers. One of them is when either the front door or the door to the garage open, since we have a 3 year old esacpe artist.

Instead of writing the actions to announce on the speakers in the automation, I put them in a script. That way if I ever need to swap out a smart speaker or add a new one, I just modify one script. That avoids updating dozens of automations every time I want to make a change!

The script also saves the volume level on the smart speakers before changing them. I created an “input number helper” for each volume I want to save. Then after a short delay, I set the volume of the speaker back to that number.

Here is the code for the script.

sequence:
  - action: input_number.set_value
    metadata: {}
    target:
      entity_id: input_number.main_room_volume
    data:
      value: >-
        {{
        state_attr('media_player.home_assistant_voice_main_room_media_player',
        'volume_level') }}
  - action: input_number.set_value
    metadata: {}
    target:
      entity_id: input_number.bedroom_volume
    data:
      value: >-
        {{ state_attr('media_player.home_assistant_voice_bedroom_media_player',
        'volume_level') }}
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 0.{{volume}}
    target:
      entity_id:
        - media_player.home_assistant_voice_main_room_media_player
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 0.4
    target:
      entity_id: media_player.home_assistant_voice_09911e_media_player
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 0.8
    target:
      entity_id:
        - media_player.thirdreality_voice_music_assistant_media_player
  - action: tts.speak
    metadata: {}
    data:
      cache: true
      media_player_entity_id: media_player.home_assistant_voice_main_room_media_player
      message: "{{message}}"
    target:
      entity_id: tts.piper
    enabled: true
  - choose:
      - conditions:
          - condition: time
            after: "07:00:00"
            before: "23:00:00"
        sequence:
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.home_assistant_voice_09911e_media_player
              message: "{{message}}"
            target:
              entity_id: tts.piper
            enabled: true
  - choose:
      - conditions:
          - condition: time
            after: "07:00:00"
            before: "20:00:00"
        sequence:
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.thirdreality_voice_music_assistant_media_player
              message: "{{message}}"
            target:
              entity_id: tts.piper
            enabled: true
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
    enabled: true
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: "{{states('input_number.main_room_volume')}}"
    target:
      entity_id:
        - media_player.home_assistant_voice_main_room_media_player
    enabled: true
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: "{{states('input_number.bedroom_volume')}}"
    target:
      entity_id: media_player.home_assistant_voice_09911e_media_player
    enabled: true
alias: Speaker Announce Message
description: ""
mode: single

As for the automation to announce when a door is opened, there is just one automation with three different triggers. It’s one trigger for each door. Those triggers have a “Trigger ID” so I can tell which door was opened and can choose the actions.

The garage door is nearby the speaker and it’s not as much of a big deal if it is opened, so the volume is lower than if the front door is opened. There’s also a one minute timer that gets started when the garage door is opened so it’s not alerting me nonstop. If the timer is active, the garage door announcement doesn’t get called.

This automations just calls that script above and passes in two variables. They are “volume” and “message”. You can name them whatever you want, but just make sure the script uses those variable names {{volume}} and {{message}}.

alias: Alarm announce exterior door open
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.alarm_panel_pro_zone_4
    to:
      - "on"
    from:
      - "off"
    id: front_door_opened
  - trigger: state
    entity_id:
      - binary_sensor.alarm_panel_pro_zone_5
    to:
      - "on"
    from:
      - "off"
    id: garage_door_opened
  - trigger: state
    entity_id:
      - binary_sensor.alarm_panel_pro_zone_6
    to:
      - "on"
    from:
      - "off"
    id: back_door_opened
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - front_door_opened
        sequence:
          - action: script.speaker_announce_message
            metadata: {}
            data:
              volume: 80
              message: Front door opened
      - conditions:
          - condition: trigger
            id:
              - garage_door_opened
          - condition: not
            conditions:
              - condition: state
                entity_id: timer.garage_door_announce_timer
                state:
                  - active
            enabled: true
        sequence:
          - action: timer.start
            metadata: {}
            target:
              entity_id: timer.garage_door_announce_timer
            data: {}
          - action: script.speaker_announce_message
            metadata: {}
            data:
              volume: 60
              message: Garage door opened
      - conditions:
          - condition: trigger
            id:
              - back_door_opened
        sequence:
          - action: script.speaker_announce_message
            metadata: {}
            data:
              volume: 90
              message: Back door opened
            enabled: false
mode: single

Super smart alerts

This next automation builds on the last one, but this time announces on the speaker near me. I’m using ESPresence and it’s been solid for years! If you want more info, watch this video.

Here is the automation that announces an exterior door has been left open. If it’s still left open two minutes after the announcement, then I get a phone notification in case I didn’t hear it.

alias: Exterior door left open notification
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.alarm_panel_pro_zone_6
    to:
      - "on"
    for:
      hours: 0
      minutes: 2
      seconds: 0
    id: back_open
  - trigger: state
    entity_id:
      - binary_sensor.alarm_panel_pro_zone_5
    to:
      - "on"
    for:
      hours: 0
      minutes: 2
      seconds: 0
    id: garage_open
  - trigger: state
    entity_id:
      - binary_sensor.alarm_panel_pro_zone_4
    to:
      - "on"
    for:
      hours: 0
      minutes: 2
      seconds: 0
    id: front_open
conditions: []
actions:
  - alias: Announce it first to the nearest speaker
    choose:
      - conditions:
          - condition: trigger
            id:
              - front_open
        sequence:
          - action: script.reed_room_speaker_announce_message
            metadata: {}
            data:
              message: Reed the front door is open
      - conditions:
          - condition: trigger
            id:
              - garage_open
        sequence:
          - action: script.reed_room_speaker_announce_message
            metadata: {}
            data:
              message: Reed the door to the garage is open
      - conditions:
          - condition: trigger
            id:
              - back_open
        sequence:
          - action: script.reed_room_speaker_announce_message
            metadata: {}
            data:
              message: Reed the back door is open
  - delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - choose:
      - conditions:
          - condition: or
            conditions:
              - condition: state
                entity_id: binary_sensor.alarm_panel_pro_zone_4
                state:
                  - "on"
              - condition: state
                entity_id: binary_sensor.alarm_panel_pro_zone_5
                state:
                  - "on"
              - condition: state
                entity_id: binary_sensor.alarm_panel_pro_zone_6
                state:
                  - "on"
        sequence:
          - choose:
              - conditions:
                  - condition: trigger
                    id:
                      - front_open
                sequence:
                  - data:
                      title: Front door still open
                      message: Close the door
                    action: script.android_notification_basic
              - conditions:
                  - condition: trigger
                    id:
                      - garage_open
                sequence:
                  - data:
                      title: Door to the garage is still open
                      message: Close the door
                    action: script.android_notification_basic
              - conditions:
                  - condition: trigger
                    id:
                      - back_open
                sequence:
                  - data:
                      title: Back door still open
                      message: Close the door
                    action: script.android_notification_basic
    alias: Notify my phone if I don't hear it
mode: single

Then the script is similar to the other announce script, but this time it only announces on one speaker. There is a big “Choose action block” that selects the speaker based on my smart watch using ESPresence.

sequence:
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.reed_room
            state:
              - studio_esp
        sequence:
          - action: media_player.volume_set
            metadata: {}
            data:
              volume_level: 0.8
            target:
              entity_id:
                - media_player.home_assistant_voice_09023f_media_player
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.home_assistant_voice_09023f_media_player
              message: "{{message}}"
            target:
              entity_id: tts.piper
            enabled: true
      - conditions:
          - condition: or
            conditions:
              - condition: state
                entity_id: sensor.reed_room
                state:
                  - kitchen_esp
              - condition: state
                entity_id: sensor.reed_room
                state:
                  - living_room_esp
        sequence:
          - action: input_number.set_value
            metadata: {}
            target:
              entity_id: input_number.main_room_volume
            data:
              value: >-
                {{
                state_attr('media_player.home_assistant_voice_main_room_media_player',
                'volume_level') }}
          - action: media_player.volume_set
            metadata: {}
            data:
              volume_level: 0.8
            target:
              entity_id: media_player.home_assistant_voice_main_room_media_player
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.home_assistant_voice_main_room_media_player
              message: "{{message}}"
            target:
              entity_id: tts.piper
            enabled: true
          - delay:
              hours: 0
              minutes: 0
              seconds: 3
              milliseconds: 0
            enabled: true
          - action: media_player.volume_set
            metadata: {}
            data:
              volume_level: "{{states('input_number.main_room_volume')}}"
            target:
              entity_id:
                - media_player.home_assistant_voice_main_room_media_player
            enabled: true
      - conditions:
          - condition: or
            conditions:
              - condition: state
                entity_id: sensor.reed_room
                state:
                  - bedroom_esp
              - condition: state
                entity_id: sensor.reed_room
                state:
                  - closet_esp
          - condition: time
            after: "07:00:00"
            before: "23:00:00"
        sequence:
          - action: input_number.set_value
            metadata: {}
            target:
              entity_id: input_number.bedroom_volume
            data:
              value: >-
                {{
                state_attr('media_player.home_assistant_voice_bedroom_media_player',
                'volume_level') }}
          - action: media_player.volume_set
            metadata: {}
            data:
              volume_level: "0.4"
            target:
              entity_id: media_player.home_assistant_voice_09911e_media_player
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.home_assistant_voice_09911e_media_player
              message: "{{message}}"
            target:
              entity_id: tts.piper
            enabled: true
          - delay:
              hours: 0
              minutes: 0
              seconds: 3
              milliseconds: 0
            enabled: true
          - action: media_player.volume_set
            metadata: {}
            data:
              volume_level: "{{states('input_number.bedroom_volume')}}"
            target:
              entity_id: media_player.home_assistant_voice_09911e_media_player
            enabled: true
      - conditions:
          - condition: state
            entity_id: sensor.reed_room
            state:
              - kids_esp
          - condition: time
            after: "07:00:00"
            before: "20:00:00"
        sequence:
          - action: media_player.volume_set
            metadata: {}
            data:
              volume_level: 0.8
            target:
              entity_id:
                - media_player.thirdreality_voice_music_assistant_media_player
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.home_assistant_voice_09911e_media_player
              message: "{{message}}"
            target:
              entity_id: tts.piper
            enabled: true
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.thirdreality_voice_music_assistant_media_player
              message: "{{message}}"
            target:
              entity_id: tts.piper
            enabled: true
      - conditions:
          - condition: state
            entity_id: sensor.reed_room
            state:
              - office_esp
          - condition: time
            after: "07:00:00"
            before: "20:00:00"
        sequence:
          - action: media_player.volume_set
            metadata: {}
            data:
              volume_level: 0.8
            target:
              entity_id:
                - media_player.thirdreality_voice_music_assistant_media_player
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.home_assistant_voice_09911e_media_player
              message: "{{message}}"
            target:
              entity_id: tts.piper
            enabled: true
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.thirdreality_voice_music_assistant_media_player
              message: "{{message}}"
            target:
              entity_id: tts.piper
            enabled: true
alias: Reed Room Speaker Announce Message
description: ""
mode: single

Faster garage notifications

Using the RATGDO Disco to detect if the car is in the garage has been great! I already had an automation to alert me if the garage door was left open for 10 minutes. So I just added another trigger for the sensor on the Disco that detects the car that gets called if it doesn’t detect a car for 1 minute.

There are two conditions. One to make sure the garage door is still open, and two if my “input switch” is turned off in case I’m washing the car or something. I just keep that switch on my garage dashboard so it’s easy to toggle on and off.

alias: Van garage door left open notification
description: ""
triggers:
  - device_id: ratgdo_device_id_number
    domain: cover
    entity_id: ratgdo_entity_id_number
    type: opened
    trigger: device
    for:
      hours: 0
      minutes: 10
      seconds: 0
  - type: turned_off
    device_id: ratgdo_device_id_number
    entity_id: ratgdo32disco_vehicle_detected
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 1
      seconds: 0
conditions:
  - condition: device
    device_id: 91d8f8e5f0b25d3419b88ff1e18181a8
    domain: cover
    entity_id: 814e310377abe36379dc0e812cc0a252
    type: is_open
  - condition: state
    entity_id: input_boolean.garage_notification_override
    state:
      - "off"
actions:
  - data:
      title: Van garage left open
      message: Garage door left open
    action: script.android_notification_basic
  - data:
      title: Van garage left open
      message: Garage door left open
    action: script.alys_phone_push_notification
mode: single

For more information on the RATGDO Disco, watch my other video.

Perfect motion lights

Motion lights can be very tricky because it seems simple, but never is. So being able to lock the lights on or off can be extremely helpful! I’m using a Zooz Z-Wave dimmer switch, but this can be done with any smart dimmer, you just have to be creative.

What’s important is that there’s an “input switch” or virtual switch that locks the lights from changing. Here is the automation to turn on the lights, but it doesn’t run if the input switch is on that is set in the condition.

alias: Kids area motion lights
description: ""
triggers:
  - type: motion
    device_id: everything_presence1_device_id_number
    entity_id: pir_entity_id_number
    domain: binary_sensor
    trigger: device
  - trigger: state
    entity_id:
      - binary_sensor.alarm_panel_pro_zone_1
    to:
      - "on"
    from:
      - "off"
conditions:
  - condition: state
    entity_id: input_boolean.kids_area_lights_lock
    state:
      - "off"
actions:
  - choose:
      - conditions:
          - condition: time
            after: "07:00:00"
            before: "19:00:00"
        sequence:
          - action: light.turn_on
            metadata: {}
            target:
              entity_id:
                - light.zooz_small_hallway_lights
                - light.front_foyer_main_lights
            data:
              brightness_pct: 100
      - conditions:
          - condition: time
            after: "19:00:00"
            before: "20:00:00"
        sequence:
          - action: light.turn_on
            metadata: {}
            target:
              entity_id: light.zooz_small_hallway_lights
            data:
              brightness_pct: 20
          - action: light.turn_on
            metadata: {}
            target:
              entity_id: light.front_foyer_main_lights
            data:
              brightness_pct: 60
      - conditions:
          - condition: time
            after: "20:00:00"
            before: "20:30:00"
        sequence:
          - action: light.turn_on
            metadata: {}
            target:
              entity_id: light.zooz_small_hallway_lights
            data:
              brightness_pct: 10
          - action: light.turn_on
            metadata: {}
            target:
              entity_id: light.front_foyer_main_lights
            data:
              brightness_pct: 30
      - conditions:
          - condition: time
            after: "20:30:00"
            before: "07:00:00"
        sequence:
          - action: light.turn_on
            metadata: {}
            target:
              entity_id: light.front_foyer_main_lights
            data:
              brightness_pct: 15
          - action: light.turn_off
            metadata: {}
            target:
              entity_id: light.zooz_small_hallway_lights
            data: {}
mode: single

There is another automation if the on or off button is pressed on the Zooz dimmer.

alias: Kids area light locked on or off button press
description: ""
triggers:
  - trigger: state
    entity_id:
      - event.zooz_small_hallway_lights_scene_001
    not_from: unavailable
    not_to: unavailable
    id: button_1
  - trigger: state
    entity_id:
      - event.zooz_small_hallway_lights_scene_002
    not_from: unavailable
    not_to: unavailable
    id: button_2
conditions: []
actions:
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 0.6
    target:
      entity_id:
        - media_player.thirdreality_voice_music_assistant_media_player
  - alias: Scene Button 1
    choose:
      - conditions:
          - condition: state
            entity_id: event.zooz_small_hallway_lights_scene_001
            attribute: event_type
            state:
              - KeyPressed
          - condition: trigger
            id:
              - button_1
            enabled: true
        sequence:
          - action: input_boolean.turn_on
            metadata: {}
            target:
              entity_id: input_boolean.kids_area_lights_lock
            data: {}
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.thirdreality_voice_music_assistant_media_player
              message: Lights locked on for one hour
            target:
              entity_id: tts.piper
            enabled: true
    enabled: true
  - alias: Scene Button 2
    choose:
      - conditions:
          - condition: state
            entity_id: event.zooz_small_hallway_lights_scene_002
            attribute: event_type
            state:
              - KeyPressed
          - condition: trigger
            id:
              - button_2
            enabled: true
        sequence:
          - action: input_boolean.turn_off
            metadata: {}
            target:
              entity_id: input_boolean.kids_area_lights_lock
            data: {}
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.thirdreality_voice_music_assistant_media_player
              message: Lights locked off
            target:
              entity_id: tts.piper
            enabled: true
          - action: light.turn_off
            metadata: {}
            target:
              entity_id: light.front_foyer_main_lights
            data: {}
      - conditions:
          - condition: state
            entity_id: event.zooz_small_hallway_lights_scene_002
            attribute: event_type
            state:
              - KeyPressed2x
          - condition: trigger
            id:
              - button_2
            enabled: true
        sequence:
          - action: input_boolean.turn_on
            metadata: {}
            target:
              entity_id: input_boolean.kids_area_lights_lock
            data: {}
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.thirdreality_voice_music_assistant_media_player
              message: Lights locked on for one hour
            target:
              entity_id: tts.piper
            enabled: true
          - action: light.turn_off
            metadata: {}
            target:
              entity_id:
                - light.front_foyer_main_lights
                - light.zooz_small_hallway_lights
            data: {}
    enabled: true
mode: parallel
max: 10

Basic light automations

Sometimes basic light automations also get the job done! One is turning on the lights to a very dim setting late at night in the main area of the house.

alias: Motion lights late at night ultra dim
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.alarm_panel_pro_zone_2
    to:
      - "on"
    from:
      - "off"
  - trigger: state
    entity_id:
      - binary_sensor.alarm_panel_pro_zone_1
    to:
      - "on"
    from:
      - "off"
conditions:
  - condition: time
    after: "23:00:00"
    before: "06:00:00"
  - condition: state
    entity_id: light.kitchen_sink_pendants
    state:
      - "off"
actions:
  - action: scene.turn_on
    metadata: {}
    target:
      entity_id: scene.kitchen_lights_ultra_dim
    data: {}
mode: single

Of course I also turn them off when no motion is detected. If you are using multiple motion sensors or mmWave sensor, then make sure there’s a condition to check all of them before turning off the lights.

alias: Main area lights off late at night if no motion
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.alarm_panel_pro_zone_2
    to:
      - "off"
    for:
      hours: 0
      minutes: 2
      seconds: 0
  - trigger: state
    entity_id:
      - binary_sensor.alarm_panel_pro_zone_1
    to:
      - "off"
    for:
      hours: 0
      minutes: 2
      seconds: 0
conditions:
  - condition: time
    after: "23:55:00"
    before: "06:00:00"
  - condition: state
    entity_id: light.kitchen_sink_pendants
    state:
      - "on"
  - condition: and
    conditions:
      - condition: state
        entity_id: binary_sensor.alarm_panel_pro_zone_1
        state:
          - "off"
        for:
          hours: 0
          minutes: 1
          seconds: 0
      - condition: state
        entity_id: binary_sensor.alarm_panel_pro_zone_2
        state:
          - "off"
        for:
          hours: 0
          minutes: 1
          seconds: 0
actions:
  - action: scene.turn_on
    metadata: {}
    target:
      entity_id: scene.living_room_off_ha
    data: {}
mode: single

Then for turning on the porch lights or the permanent holiday lights, I’m just using the sunset and turning them off at 10pm.

alias: "Permanent house lights on "
description: ""
triggers:
  - trigger: sun
    event: sunset
    offset: 0
conditions: []
actions:
  - action: light.turn_on
    metadata: {}
    target:
      entity_id: light.jellyfish_lights_house_lights
    data:
      effect: Custom/White
      brightness_pct: 100
mode: single
alias: Permanent house lights off
description: ""
triggers:
  - trigger: time
    at: "22:00:00"
conditions: []
actions:
  - action: light.turn_off
    metadata: {}
    target:
      entity_id: light.jellyfish_lights_house_lights
    data: {}
mode: single

Automatic animal feeders

To automatically feed Annie, it’s pretty simple. Just have the automation press the button to let food out, and then it waits for 15 seconds and presses it again. I’m using the Aqara pet feeder and the serving size can be changed for the device. It uses Zigbee and I can configure all of that in Home Assistant.

The automation skips the actions if we are on vacation so it’s not just overflowing with food, and it can be manually triggered by the kids. I made a button on the dashboard that if Annie is really hungry and they want to feed her a little bit early, they can press the button to run the automation. Once it runs it can’t run again for that meal so she doesn’t get overfed.

alias: Feed Annie dog food every day
description: ""
triggers:
  - trigger: time
    at: "07:00:00"
    enabled: true
  - trigger: time
    at: "16:45:00"
conditions:
  - condition: state
    entity_id: input_boolean.vacation_mode
    state:
      - "off"
  - condition: template
    value_template: >-
      {{ (as_timestamp((now() - timedelta( hours = 2 )))) >
      (state_attr('input_datetime.annie_last_fed', 'timestamp')) }}
actions:
  - data:
      datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
    target:
      entity_id:
        - input_datetime.annie_last_fed
    action: input_datetime.set_datetime
  - action: timer.finish
    metadata: {}
    target:
      entity_id: timer.manually_feed_annie_timer
    data: {}
  - action: script.speaker_announce_message
    metadata: {}
    data:
      volume: 60
      message: I am going to feed Annie
  - action: button.press
    metadata: {}
    target:
      entity_id: button.aqara_annie_pet_feeder_feed
    data: {}
    enabled: true
  - delay:
      hours: 0
      minutes: 0
      seconds: 15
      milliseconds: 0
    enabled: true
  - action: button.press
    metadata: {}
    target:
      entity_id: button.aqara_annie_pet_feeder_feed
    data: {}
    enabled: true
mode: single

Annie is thirsty

To know if Annie’s water bowl is dry, the logic is just the opposite of if there’s a water leak. If the water leak sensor is dry then it shows up on the dashboard so we can see it quickly.

But at least once a day during dinnertime, it also checks to see if her bowl is dry. If so, it announces to the family she needs water.

alias: Annie has an empty water bowl annoucement
description: ""
triggers:
  - trigger: time
    at: "17:15:00"
conditions:
  - condition: state
    entity_id: binary_sensor.aqara_water_leak_annie
    state:
      - "off"
actions:
  - action: script.speaker_announce_message
    metadata: {}
    data:
      volume: 80
      message: Hey family. Ruff ruff. Annie has an empty water bowl.
mode: single

Powerful dinner button

Just before 5pm a big button appears on the family dashboard that says “Dinner Time.” When pressed, it announces to the kids that dinner is ready and if my phone is not nearby, it also sends me a notification.

Then it also turns off the Apple TV, plays classical music, and starts a 30 minute timer.

alias: Dinner is ready annoucement
sequence:
  - action: input_boolean.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: input_boolean.dinner_is_ready
  - action: script.speaker_announce_message
    metadata: {}
    data:
      volume: 90
      message: Dinner is ready
  - choose:
      - conditions:
          - condition: not
            conditions:
              - condition: state
                entity_id: sensor.hvac_reed_area
                state: hvac_kitchen
        sequence:
          - data:
              title: Dinner is ready
              message: go eat!
            action: script.android_notification_basic
      - conditions:
          - condition: not
            conditions:
              - condition: state
                entity_id: sensor.hvac_aly_area
                state: hvac_kitchen
        sequence:
          - data:
              title: Dinner is ready
              message: go eat!
            action: script.alys_phone_push_notification
    alias: Notify Reed or Aly's phone
  - action: script.mass_music_kitchen_dynamic
    metadata: {}
    data:
      playlist_name: Reeds Classical
      shuffle_mode: true
      volume: 35
  - action: remote.send_command
    metadata: {}
    target:
      entity_id: remote.family_room_tv
    data:
      num_repeats: 1
      delay_secs: 0.4
      hold_secs: 0
      command: suspend
  - action: timer.start
    metadata: {}
    target:
      entity_id: timer.dinner_timer
    data:
      duration:
        hours: 0
        minutes: 30
        seconds: 0
description: ""

Defeating kids with technology

If the kids or anyone tries to start using the TV during the dinner timer, it physically kills power to the TV. Nice!

alias: Family room tv turns off at dinner time smart outlet
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.third_reality_dual_plug_power
    for:
      hours: 0
      minutes: 0
      seconds: 3
    above: 20
conditions:
  - condition: state
    entity_id: input_boolean.tv_lights_lock
    state:
      - "off"
  - condition: state
    entity_id: input_boolean.babysitter_override
    state:
      - "off"
  - condition: state
    entity_id: timer.dinner_timer
    state:
      - active
actions:
  - action: switch.turn_off
    metadata: {}
    target:
      entity_id: switch.third_reality_dual_plug_switch
    data: {}
mode: single

Auto arming cameras

The easiest way to know when to receive security camera notifications is when the alarm is active. I take a snapshot of the camera that detected someone, and then send myself a critical notification with that snapshot attached.

Here’s the automation to take the snapshot if the camera detects a person when the alarm is armed.

alias: Outdoor cameras detect someone while armed
description: ""
triggers:
  - entity_id:
      - binary_sensor.g4_bullet_backyard_person_detected
    to: "on"
    trigger: state
    id: g4bullet_detected
    enabled: true
  - trigger: state
    entity_id:
      - binary_sensor.elite_floodlight_camera_person_2
    to: "on"
    id: floodlight_detected
    enabled: true
  - trigger: state
    entity_id:
      - binary_sensor.duo_2_poe_person
    to: "on"
    enabled: true
    id: duo2_detected
  - trigger: event
    event_type: driveway_line_crossed_event
    id: driveway_camera
    enabled: true
  - trigger: state
    entity_id:
      - binary_sensor.reolink_lumus_pro_person
    to:
      - "on"
    id: back_patio_camera
conditions:
  - condition: or
    conditions:
      - condition: state
        entity_id: alarm_control_panel.alarmo
        state:
          - armed_home
      - condition: state
        entity_id: alarm_control_panel.alarmo
        state:
          - armed_away
      - condition: state
        entity_id: input_boolean.vacation_mode
        state: "on"
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - g4bullet_detected
        sequence:
          - target:
              entity_id:
                - camera.g4_bullet_backyard_high
            data:
              filename: /config/www/tmp/camera_snap.jpg
            action: camera.snapshot
      - conditions:
          - condition: trigger
            id:
              - floodlight_detected
        sequence:
          - target:
              entity_id:
                - camera.elite_floodlight_camera_fluent_2
            data:
              filename: /config/www/tmp/camera_snap.jpg
            action: camera.snapshot
      - conditions:
          - condition: trigger
            id:
              - duo2_detected
        sequence:
          - target:
              entity_id:
                - camera.duo_2_poe_fluent
            data:
              filename: /config/www/tmp/camera_snap.jpg
            action: camera.snapshot
      - conditions:
          - condition: trigger
            id:
              - driveway_camera
        sequence:
          - target:
              entity_id:
                - camera.g4_pro_driveway_high
            data:
              filename: /config/www/tmp/camera_snap.jpg
            action: camera.snapshot
      - conditions:
          - condition: trigger
            id:
              - back_patio_camera
        sequence:
          - target:
              entity_id: camera.reolink_lumus_pro_fluent
            data:
              filename: /config/www/tmp/camera_snap.jpg
            action: camera.snapshot
  - data:
      title: Someone is spotted
      message: Person detected on this camera
    action: script.notification_critical_camera_image
mode: single

Here is the script to send myself a critical notification with the image.

action: notify.mobile_app_iphone_pro_15
data:
  title: " {{title}} "
  message: " {{message}} "
  data:
    push:
      sound:
        name: default
        critical: 1
        volume: 1
    attachment:
      content-type: jpeg
      url: https://home_assistant_url/local/tmp/camera_snap.jpg
enabled: true

Water leak fail safe

Droplet has been an easy way to detect if water is flowing in my house or not. They have notifications in the app to alert you if it thinks there is something to check out. This works okay, but I prefer to alert myself if I’m away and water is running.

alias: Droplet detects water leaking while we are away
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.droplet_flow_rate_2
    for:
      hours: 0
      minutes: 1
      seconds: 0
    above: 1
conditions:
  - condition: state
    entity_id: alarm_control_panel.alarmo
    state:
      - armed_away
actions:
  - action: script.android_notification_critical
    data:
      title: Possible Water leak!
      message: Droplet says water is running
    enabled: true
mode: single

Fan fully automated

My family really missed the fan being automated, so this was one of the first automations I set up here. Mainly because it’s so hot here in Arizona!

One automation turns on the fan when the HVAC system starts running.

alias: Turn on Dreo Family Room Fan when HVAC is cooling
description: ""
triggers:
  - trigger: state
    entity_id:
      - climate.kitchen_homekit_2
    to: cooling
    attribute: hvac_action
conditions:
  - condition: time
    after: "07:00:00"
    before: "23:00:00"
actions:
  - action: script.turn_on_dreo_family_room_fan
    metadata: {}
    data: {}
mode: single

Then another turns off the fan if the mmWave sensor doesn’t detect anyone, or if the HVAC system turns off and no one is in the room.

alias: Turn off Family room Dreo fan if no one is around
description: ""
triggers:
  - trigger: state
    entity_id:
      - climate.kitchen_homekit_2
    to:
      - idle
    attribute: hvac_action
  - trigger: state
    entity_id:
      - binary_sensor.apollo_r_pro_1_370ba8_ld2450_presence
    to:
      - "off"
    for:
      hours: 0
      minutes: 5
      seconds: 0
conditions:
  - condition: state
    entity_id: binary_sensor.apollo_r_pro_1_370ba8_ld2450_presence
    state: []
    for:
      hours: 0
      minutes: 2
      seconds: 0
actions:
  - action: script.turn_off_dreo_family_room_fan
    metadata: {}
    data: {}
mode: single

Improved doorbell

Cutting down on doorbell notifications is a MUST! The best way to do that is to only be notified if the front door has been closed for 30 seconds or a minute. Also, only have the automation run the actions once every 30 seconds so it’s not a nonstop stream of notifications.

alias: Front Doorbell Motion
description: ""
triggers:
  - entity_id:
      - binary_sensor.g4_doorbell_2_person_detected
    to: "on"
    trigger: state
conditions:
  - condition: template
    value_template: >-
      {# run once every 30 sec #}

      {% if states.automation.front_doorbell_motion.attributes.last_triggered is
      not none %}
        {% if as_timestamp(now()) | int - as_timestamp(states.automation.front_doorbell_motion.attributes.last_triggered) 
        | int > (1 * 30) %} true {% else %} false
        {% endif %}
      {% else %}
        true
      {% endif %}
  - condition: state
    entity_id: input_boolean.doorbell_notification_override
    state: "off"
  - condition: or
    conditions:
      - condition: state
        entity_id: binary_sensor.alarm_panel_pro_zone_4
        state:
          - "off"
        for:
          hours: 0
          minutes: 0
          seconds: 30
        enabled: true
      - condition: state
        entity_id: input_boolean.babysitter_override
        state:
          - "on"
    enabled: true
actions:
  - target:
      entity_id:
        - camera.g4_doorbell_2_high
    data:
      filename: /config/www/tmp/doorbell_snap.jpg
    action: camera.snapshot
  - data:
      title: Someone is at the front door
      message: the doorbell detected a person
    action: script.android_notification_doorbell_image
  - data:
      title: Someone is at the front door
      message: the doorbell detected a person
    action: script.aly_notification_doorbell_image
mode: single

Keeping it clean

Usually our robot vacuum runs automatically when everyone leaves the house. Because I don’t see it clean, I forget to empty the dirty water tank, which gets gross fast!

I set up the automation that if the robot starts drying the mop and I’m home, then I notify myself to empty the water tank. If I’m not home but I get home later, then I get the notification when I walk in the door so I don’t forget.

alias: Notify me to clean vacuum dirty mop tank when I get home
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.saros_20_dock_mop_drying
    to:
      - "on"
  - trigger: state
    entity_id:
      - sensor.reed_current_location_phone
    to:
      - home
conditions:
  - condition: state
    entity_id: input_boolean.robot_vac_ran_while_away
    state: "on"
  - condition: state
    entity_id: sensor.reed_current_location_phone
    state: home
  - type: is_running
    condition: device
    device_id: dock_device_id_number
    entity_id: dock_drying_entity_id_number
    domain: binary_sensor
actions:
  - data:
      title: Need to clean robot vacuum dock
      message: do it now
    action: script.android_notification_basic
  - action: input_boolean.turn_off
    metadata: {}
    target:
      entity_id: input_boolean.robot_vac_ran_while_away
    data: {}
mode: single

mmWave motion lights

The automation for turning on the lights when we walk into the den is pretty simple. There is just two crucial conditions.

One that checks to make sure the Denon receiver is not on. That way the lights don’t turn on in the middle of a movie if the kids are walking around.

The other condition makes sure the lights are off for at least 10 seconds. That way the lights don’t turn back on after turning them off from the wall switch.

alias: Den lights on
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.aqara_fp1e_mud_room
    to:
      - "on"
conditions:
  - condition: device
    device_id: denon_device_id_number
    domain: media_player
    entity_id: media_player.denon_avr_x4700h
    type: is_off
  - condition: state
    entity_id: light.govee_floor_lamp_3
    state:
      - "off"
    for:
      hours: 0
      minutes: 0
      seconds: 10
actions:
  - choose:
      - conditions:
          - condition: time
            after: "07:00:00"
            before: "17:00:00"
        sequence:
          - action: switch.turn_on
            metadata: {}
            target:
              entity_id: switch.den_light_switch
            data: {}
            enabled: true
  - action: script.turn_on
    metadata: {}
    target:
      entity_id: script.den_lights_on
    data: {}
    enabled: true
  - action: scene.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: scene.den_neutral_white
    enabled: true
mode: single

Projector and thermostat

When we watch a movie in the den, we set the thermostat to “Home.” This comfort setting in Ecobee uses the sensor in the den to average out the temperature, so it never gets too hot in there. It gets triggered when the Denon receiver turns on.

alias: Den theater room on turn on AC
description: ""
triggers:
  - trigger: state
    entity_id:
      - media_player.denon_avr_x4700h
    to:
      - "on"
actions:
  - device_id: thermostat_device_id_number
    domain: select
    entity_id: thermostat_entity_id_number
    type: select_option
    option: home
    enabled: true
mode: single

Buttons and auto lights

The Sofabaton X2 integrates extremely well with Home Assistant. It can send MQTT requests when a button on the remote is pressed to trigger the automation.

Here is an example of a button press that turns off all of the lights.

alias: Sofabaton MQTT kitchen lights off
description: ""
triggers:
  - trigger: mqtt
    options:
      topic: FC12345679/up
      payload: "{\"device_id\":5,\"key_id\":1}"
conditions: []
actions:
  - action: scene.turn_on
    metadata: {}
    data: {}
    target:
      entity_id:
        - scene.living_room_off_ha
  - action: switch.turn_off
    metadata: {}
    target:
      entity_id: switch.den_light_switch
    data: {}
  - action: script.turn_on
    metadata: {}
    target:
      entity_id: script.den_lights_off
    data: {}
mode: single

They give you the MQTT topic in the Sofabaton app when making the button presses, so it’s not as difficult as it looks.

Actionable notification

If our robot vacuum hasn’t run in 3 days and I’m home, I get an actionable notification at 9pm.

alias: Robot vacuum notification prompt
description: ""
triggers:
  - at: "21:00:00"
    trigger: time
conditions:
  - condition: template
    value_template: >-
      {{ (as_timestamp((now() - timedelta( days = 3 )))) >
      (state_attr('input_datetime.robot_vacuum_running_input', 'timestamp')) }}
  - condition: state
    entity_id: sensor.reed_current_location_phone
    state: home
actions:
  - data:
      title: Robot vac has not run lately
      message: Hold down on this notification to see button to start
      replyevent: robotvacstartaction
      buttontitle: Start Vacuum
    action: script.alys_phone_push_notification_actionable
  - data:
      title: Robot vac has not run lately
      message: Hold down on this notification to see button to start
      replyevent: robotvacstartaction
      buttontitle: Start Vacuum
    action: script.actionable_notification_android
mode: single

If I click on the notification action button, it sends an event “robotvacstartaction” that can trigger another notification. This one sets the robot to quiet mode, only vacuum not mop, and to only go in certain rooms.

alias: Robot vacuum clean action from event
description: ""
triggers:
  - event_type: mobile_app_notification_action
    event_data:
      action: robotvacstartaction
    trigger: event
conditions: []
actions:
  - action: vacuum.set_fan_speed
    metadata: {}
    target:
      entity_id: vacuum.saros_20
    data:
      fan_speed: quiet
  - action: vacuum.clean_area
    metadata: {}
    target:
      entity_id: vacuum.saros_20
    data:
      cleaning_area_id:
        - kitchen
        - living_room
        - dining_room
  - action: select.select_option
    metadata: {}
    target:
      entity_id: select.saros_20_mop_intensity
    data:
      option: "off"
  - action: vacuum.start
    metadata: {}
    data: {}
    target:
      device_id: vacuum_device_id_number
mode: single

Crashing in bed

Laying down in bed late at night closes up everything in the house. It announces on the speaker near by that it ran if the lights are on in the bedroom. If the lights are off then it just flashes my bed lamp on and off to let me know it ran.

alias: Lay down in bed and close everything up at night
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.slumbertek_v2_bed_sensor
    to:
      - "on"
    for:
      hours: 0
      minutes: 0
      seconds: 15
conditions:
  - condition: time
    before: "23:55:00"
    after: "23:00:00"
  - condition: template
    value_template: >
      {% if states.automation.locked_up_night_recap.last_triggered is not none
      %}
                {% if as_timestamp(now()) | int - as_timestamp(states.automation.locked_up_night_recap.attributes.last_triggered) | int > 21600 %} true {% else %} false
                {% endif %}
              {% else %}
              false
              {% endif %}
  - condition: state
    entity_id: input_boolean.babysitter_override
    state: "off"
actions:
  - device_id: alarm_device_id_number
    domain: alarm_control_panel
    entity_id: alarm_entity_id_number
    type: arm_home
  - action: automation.trigger
    metadata: {}
    data:
      skip_condition: true
    target:
      entity_id: automation.good_night
  - choose:
      - conditions:
          - condition: state
            entity_id: light.bed_light_group
            state:
              - "on"
        sequence:
          - action: input_number.set_value
            metadata: {}
            target:
              entity_id: input_number.bedroom_volume
            data:
              value: >-
                {{
                state_attr('media_player.home_assistant_voice_bedroom_media_player',
                'volume_level') }}
          - action: media_player.volume_set
            metadata: {}
            data:
              volume_level: 0.2
            target:
              entity_id:
                - media_player.home_assistant_voice_bedroom_media_player
            enabled: true
          - action: tts.speak
            metadata: {}
            data:
              cache: true
              media_player_entity_id: media_player.home_assistant_voice_bedroom_media_player
              message: The alarm has been armed and everything turned off in the house.
            target:
              entity_id: tts.piper
            enabled: true
          - delay:
              hours: 0
              minutes: 0
              seconds: 3
              milliseconds: 0
            enabled: true
          - action: media_player.volume_set
            metadata: {}
            data:
              volume_level: "{{states('input_number.bedroom_volume')}}"
            target:
              entity_id: media_player.home_assistant_voice_09911e_media_player
            enabled: true
    default:
      - action: light.turn_on
        metadata: {}
        target:
          entity_id: light.hue_bed_right
        data: {}
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - action: light.turn_off
        metadata: {}
        target:
          entity_id: light.hue_bed_right
        data: {}
mode: single