I have an automation which works fine, but ignores the delay. HA is in latest version.
Under “action:” are the following 3 service calls.
call ( - service: media_player.volume_set ) sets the volume loud
call ( - service: tts.google_say ) plays a message on the Homepod
Then I want to make a delay of 10sec ( - delay: "00:00:10" )
call ( - service: media_player.volume_set ) sets the volume low
If I run the automation manually without the delay, the volume is reduced before the message ends, but the volume is reduced.
But if I try to put the delay between 2. and 3. call the volume stays loud.
I tried to use a wait_template instead, but the result is the same.
In the timeline all 3 calls and the delay are executed.
I need your help. Sorry for my not working back-ticks.
alias: MuelltonnenLastCall
description: auf den Homepod
trigger:
- platform: time
at: "07:40:00"
condition:
- condition: and
conditions:
- condition: numeric_state
entity_id: sensor.abfallnotify
below: "1"
action:
- service: media_player.volume_set
data_template:
entity_id:
- media_player.buro
volume_level: 0.8
- service: tts.google_say
data:
entity_id: media_player.buro
language: de
message: >-
bla-bla-bla...
- delay: "00:00:10"
# Wait until media player is stopped
#- delay: 9 -> does not work
#- alias: "Wait until media player is stopped"
# wait_template: "{{ is_state('media_player.buro', 'stop') }}" -> does not work
- service: media_player.volume_set
data_template:
entity_id:
- media_player.buro
volume_level: 0.3
mode: single
I don’t use tts.google_say so I can’t confirm this, but other users have had success usinga wait for trigger like:
- alias: "Wait for tts to finish"
wait_for_trigger:
- platform: state
entity_id: media_player.buro
from: "playing"
to: "idle"
If the playing>idle transition doesn’t work for your devices and service, take a look at the history graph for the device state to find the appropriate transition.
Tried this, but the volume is still 0.8 at the end, although I can see “Mediaplayer: Set Volume Homepod” in the timeline. Something seems to be preventing the volume from being switched.
But What?
This method requires at least two seconds delay before the wait for trigger.
HA needs to create the TTS file and send it to the media player and the media player needs to update it’s state.
But I don’t think this is the issue.
Do you see anything in the traces or logs?
I just found out that the volume in developer tools → state remains 0.8, but when I start for example another song on the homepod, it changes in that moment to 0.3. So, the change is done, but not shown in developer tools → state. With that I can live. Thank you all.