With a toddler running around the house we (ok, mostly me 🤦‍♂️) have to make sure we close doors. This is especially true for our basement door which is a set of steep stairs down to the...basement. Inspired by this blog post at LABZILLA.io and this post on the Home Assistant Community forum I decided to add my own flavor of door chimes to my Home Assistant.

Scenario: when the basement door is left open for 5 seconds, make an announcement across all Media Player speakers and continue to announce until the door is closed. In my case, I’ll announce to Google Minis and an Amazon Echo Dot. It has worked incredibly well; not because we forget to close the door and we're benefited by the reminder, but because we don't want the annoyance of the announcements in the first place.

HARDWARE

To install and set up your HUSBZB-1 and connect your devices, see this tutorial/video: https://techtechandmoretech.com/guides/home-assistant-zigbee/

SETUP

UPDATED - 11/14/2020 - as someone pointed out on Reddit, this can be done with a single automation using a Repeat action

In automations.yaml add the following, remembering to update your binary_sensor.[your_entity]

Don't want to mess around with the Yaml code? For screenshots of the front-end automation, click here: Automation Screenshots.

- id: '139853231225565597'
  alias: Single automation to check for open door
  description: Check if the door is open and announce to Google Nest every 5 seconds until it closes.
  trigger:
    - platform: state
      entity_id: binary_sensor.top_stairs_open_closed
      to: 'on'
  condition:
    - condition: time
      before: '19:00:00'
      after: '07:00:00'
  mode: single
  action:
    - alias: Repeat the sequence UNTIL the conditions are true
      repeat:
        sequence:
          # Run this service until condition below is true (door closed = state of 'off')
          - service: tts.google_translate_say
            data:
              message: Basement door open.
            entity_id: media_player.kitchen_display, media_player.basement_speaker
          # Give it time to complete... 5 seconds.  This will have to be added via Yaml in the UI.
          - delay:
              milliseconds: 5000
        until:
          # Did it work?
          - condition: state
            entity_id: binary_sensor.top_stairs_open_closed
            state: 'off'

Old Setup

Timer

There are five aspects to the door chime automation. One is a timer that you’ll put in configuration.yaml and four automations that you’ll put in automations.yaml

The easy part is adding the timer.

In configuartion.yaml add the following and restart your Home Assistant:

timer:
  looper:
    duration: 00:00:06

Change the duration to how frequently you want the chime to play; keep in mind it should be longer than the time it takes for the message to play. Mine is set to 6 seconds as my message is only "Basement door open"

Automations

You can use the frontend for adding the automations or you can edit configuration.yaml manually. For screenshots of the front-end automations, click here: Automation Screenshots.

In automations.yaml add the following four automations:

Automation #1

If the basement door is open for 5 seconds, start the timer

- id: '1602533646585'
  alias: Basement Door Open - Start Timer
  description: Bsmnt door open > 5 secs b/t 7am-7pm, start timer.looper
  trigger:
  - entity_id: binary_sensor.top_stairs_open_closed 
    from: 'off'
    platform: state
    to: 'on'
    for: '00:00:05'
  condition:
  - after: 07:00:00
    before: '19:00:00'
    condition: time
  action:
  - service: timer.start
    entity_id: timer.looper
  mode: single

Automation #2

Play the message Basement Door Open

- id: '1234309432248'
  alias: Looper timer started
  trigger:
  - event_data:
      entity_id: timer.looper
    event_type: timer.started
    platform: event
  action:
  - data:
      message: Basement door open.
    entity_id: media_player.kitchen_display, media_player.basement_speaker
    service: tts.google_translate_say
  - data:
      data:
        type: announce
      message: Basement door open.
      target:
      - media_player.martin_s_echo_dot
    service: notify.alexa_media
  mode: single

Automation #3

Check the state of the door sensor when timer.looper finishes; if its 'on' start the timer again

- id: '124940205824559403'
  alias: Looper timer finished?
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.looper
  condition:
    condition: state
    entity_id: binary_sensor.top_stairs_open_closed
    state: 'on'
  action:
  - service: timer.start
    entity_id: timer.looper

Automation #4

When the door closes, stop the timer. You can also add a service to say "Basement Door Closed" but I found that was unnecessary

- id: '1556493900287'
  alias: Door closed, stop timer.looper
  trigger:
  - entity_id: binary_sensor.top_stairs_open_closed
    from: 'on'
    platform: state
    to: 'off'
  condition: []
  action:
  - service: timer.finish
    entity_id: timer.looper


Comments

comments powered by Disqus