Having some trouble here and cant figure it out! Thought this would be a simple automation to alert me when the fridge door had been left open but cant get it working. If i change the repeat to a count instead of until, it works, but i cant see anything wrong with the until part! Obviously a count doesnt help if i shut the door when its still going off! Appreciate any help!
Ok ive tried using state conditions as well. Weirdly if i put the repeat until condition as the sensor being “on” (i.e. door is open) it plays the sound once and then stops. If i set it as “off” (i.e. door is shut) it doesnt play at all. Now im completely lost!
EDIT: also added the time delay as suggested!
Ok i think ive figured it out. I think the message to play the sound was being sent so quickly it was spamming the alexa or something so i added a 5 second delay after the sound and it seems to be working now. The sound kept playing for ages after i shut the door like it was in a queue to be played so it appeared to be a faulty loop. The 5 second buffer gave the current sound time to play before the next request was sent. Thanks for your help!
An alternative to a fixed delay is to wait until the media player changes state from playing to idle.
- wait_for_trigger:
- platform: state
entity_id: media_player.kitchen_echo_show
from: 'playing'
to: 'idle'
timeout: '00:00:05'
The timeout is effectively an insurance policy to ensure wait_for_trigger doesn’t wait for more than X seconds.
This technique is more useful when the duration of the media content to be played is variable. If you know the media content’s duration in advance then using a fixed delay is simpler.