My doorbell automation play doorbell.mp3 on Google home speaker when push the doorbell button. I want when I open the door my door bell will mute.
Do I need separate automation or is that possible in template ?
Here is my doorbell automation
- id: '16097843297'
alias: Doorbell
description: ''
trigger:
- entity_id: binary_sensor.doorbell
from: 'off'
platform: state
to: 'on'
condition: []
action:
- service: media_player.play_media
data:
entity_id: media_player.home_assistant_speaker
media_content_id: https://xxx.duckdns.org/local/doorbell/doorbell.mp3
media_content_type: music
mode: single
Use wait for trigger, and set the trigger to the door changing from closed to open. Set the timeout to the length of the audio clip, and don’t continue on timeout. Then just use media_player.volume_set and set it to 0. Add a delay for 10 seconds (or something like that) and then call media_player.volume_set again.
Not really useful imo. He wants it mute when it’s playing and he opens the door. In other words, if he doesn’t open, the doorbell.mp3 file must continue to play. So no timeouts
One way would be, when door sensor is triggered, then mute volume. Only bad thing about this is that the speaker remains muted (vol 0) and you have to raise volume again. entity id is “home_assistant_speaker”? So i assume a dedicated speaker for HA only? If so, put vol at X when starting the automation so you don’t have that issue.
Other way could be, as you play media, when door sensor triggered end it. You could achieve this by putting an extra trigger check, if doorsensor from off to on (closed to open) and in thee action use if is_state and define when door closed, doorbell press. play sound. and other if, if playing and door sensor == on (or open) then command would be to end the media player.