Hey
I had a working TTS google welcome-home message automation for when I walked thru the frontdoor but somewhere in some update of Home Assistant it stopped working and I dont know when.
I have also tried to play a TTS via services in HA but nothing. It caches the .mp3 in tts-folder but it cant play it. The .mp3 can be played on a computer.
My code for trying to play via services in HA:
I NOT getting any error-messages or invalid code tha HA reacts on.
Help plz.
My code in automation:
automation:
- alias: 'Välkommen Hem'
trigger:
platform: state
entity_id: sensor.ytterdorr_status
to: 'Öppen'
condition:
condition: and
conditions:
- condition: time
after: '09:00:00'
before: '18:00:00'
- condition: or
conditions:
- condition: state
entity_id: sensor.niclas_status
state: 'Anlände'
- condition: state
entity_id: sensor.sara_status
state: 'Anlände'
action:
- service: script.welcome_home
data_template:
speech_message: >
{% if is_state('sensor.niclas_status', 'Anlände') and is_state('sensor.sara_status', 'Anlände') %}
{{ [
"Välkommen hem Sara och Niclas" ,
"Kungen och Drottningen är hemma"
] | random }}
{% elif is_state('sensor.niclas_status', 'Anlände') %}
{{ [
"Välkommen hem Niclas" ,
"Kungen Niclas är hemma"
] | random }}
{% else %}
{{ [
"Välkommen hem Sara" ,
"Drottningen är hemma. Välkommen hem Sara" ,
"Husets sötnos Sara är hemma"
] | random }}
{% endif %}
script:
welcome_home:
alias: "Välkomst meddelande"
sequence:
- service_template: script.sonos_{{'playing' if states.media_player.kok.state == 'playing' else 'notplaying'}}
data_template:
sonos_entity: media_player.kok
volume: 0.45
message: "{{ speech_message }}"
sonos_playing:
alias: "Sonos Playing"
sequence:
- service: sonos.snapshot
data_template:
entity_id: "{{ sonos_entity }}"
- service: sonos.unjoin
data_template:
entity_id: "{{ sonos_entity }}"
- service: media_player.volume_set
data_template:
entity_id: "{{ sonos_entity }}"
volume_level: "{{ volume }}"
- delay: '00:00:05'
- service: tts.google_translate_say
data_template:
entity_id: "{{ sonos_entity }}"
message: "{{ message }}"
- delay: '00:00:03'
- service: sonos.restore
data_template:
entity_id: "{{ sonos_entity }}"
sonos_notplaying:
alias: "Sonos Not PLaying"
sequence:
- service: media_player.volume_set
data_template:
entity_id: "{{ sonos_entity }}"
volume_level: "{{ volume }}"
- delay: '00:00:05'
- service: tts.google_translate_say
data_template:
entity_id: "{{ sonos_entity }}"
message: "{{ message }}"
- delay: '00:00:03'
- service: media_player.volume_set
data_template:
entity_id: media_player.kok
volume_level: 0.25
- service: media_player.select_source
data_template:
entity_id: media_player.kok
source: >
{% if is_state('sensor.niclas_status', 'Anlände') and is_state('sensor.sara_status', 'Anlände') %}
STAR FM 96.3 (60-tal)
{% elif is_state('sensor.niclas_status', 'Anlände') %}
Raubtier
{% elif is_state('sensor.sara_status', 'Anlände') %}
NRJ Sverige 105.1 (Populärmusik)
{% else %}
{% endif %}