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