Hi
I’am using google tts for broadcast as a script for different functions i my house. Today i changed this script from notify.google_assistant to google TTS to be able to control where it reads my message.
I have one group i google home with the name media_player.overvaning where i normally play internet-radio and spotify and a group named media_player.villan where my message plays.
The problem then, when i trigger this script it first pause media playing and then it check volume on every media_player and store it in input_number. Then it set volume to a little louder an then reads my message. Next this script reset volume to value before the script started and then playmedia that was paused.
Every time this script run, home-assistant create a new media_player with a additional extra number after media_player.overvaning_1 media_player.overvaning_2 and so on. I have controlled my yaml several times and cant find any problem. Have any of you had a similar problem?
The Code:
media_on:
alias: Media On
sequence:
- service: media_player.media_pause
data_template:
entity_id: >
{% if is_state("media_player.overvaning", "off") and is_state("media_player.kallare", "playing") %}
media_player.kallare
{% elif is_state("media_player.kallare", "off") and is_state("media_player.overvaning", "playing") %}
media_player.overvaning
{% else %}
media_player.overvaning,media_player.kallare
{% endif %}
- delay:
seconds: 0.5
- service: media_player.volume_set
data:
entity_id: media_player.villan
volume_level: '0.5'
- delay:
seconds: 0.8
- service: tts.google_say
entity_id: media_player.villan
data_template:
message: '{{ speak_message }}'
language: 'sv'
- delay:
seconds: 8
- service: media_player.volume_set
data_template:
entity_id: media_player.matsal_main
volume_level: '{{ states("input_number.media_matrum_2") | float }}'
- service: media_player.volume_set
data_template:
entity_id: media_player.kallare
volume_level: '{{ states("input_number.media_kallare") | float }}'
- service: media_player.volume_set
data_template:
entity_id: media_player.allrum_uppe
volume_level: '{{ states("input_number.media_allrum_uppe") | float }}'
- service: media_player.media_play
data_template:
entity_id: >
{% if is_state("media_player.overvaning", "off") and is_state("media_player.kallare", "paused") %}
media_player.kallare
{% elif is_state("media_player.kallare", "off") and is_state("media_player.overvaning", "paused") %}
media_player.overvaning
{% else %}
media_player.overvaning,media_player.kallare
{% endif %}
Best regards Andreas