Alexa door chime/buzzer

Apologies first of all. Although I have been using Home Assistant for several months (first on a Hyper-V VM, now on a NUC using HAOS), I am relatively new to Python, YAML and templating in HA.

I am using the following script as part of an automation on my front and back door contact sensors, where Alexa plays a buzzer/chime from the Echo in my dining room when the door is opened:

alias: Alexa Door Buzzer
sequence:
  - service: media_player.volume_set
    data:
      volume_level: 1
    target:
      entity_id: media_player.dining_room
  - service: media_player.play_media
    target:
      entity_id: media_player.dining_room
    data:
      media_content_type: sound
      media_content_id: buzzers_pistols_01
  - service: media_player.volume_set
    data:
      volume_level: 0.5
    target:
      entity_id: media_player.dining_room
mode: single
icon: mdi:doorbell

This script works fine when I run it manually, but never seems to work when coupled up one of the door contact sensors in an automation such as:

alias: Back Door Buzzer
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.back_door_opening
    to: "on"
    from: "off"
action:
  - service: script.door_buzzer_alexa
    data: {}
mode: single

Can anyone tell me where I am going wrong please? Also, if anyone can signpost me to any good HA templating resources that would be appreciated too.

Many Thanks

Check to make sure that the entity_id is correct and the states are actually ‘on’ & ‘off’ in dev tools. They should be but it always helps to check to be sure especially if something isn’t working correctly.

if that is correct then try removing the "from: ‘off’ " line just in case there is some strange transition between ‘off’ & ‘on’.

lastly you could add an “id:” to the automation that allows you to use the automation trace function to see why it isn’t triggering.

All sorted now. I used the dev tools as you mentioned and realised that there were 2 similar entities on each contact sensor, but I was using the wrong one in all cases! Simple enough to correct though once I realised. Much appreciated and thanks for your help and advice.

1 Like