My tts service is working fine (a Sonos - I can type “Text to Speak” into the Home page entity and it speaks fine). Cant use it in an automation though. Weird thing is it was working for a time under one automation but refused to work under and almost identical automation. I’m assuming it some sort of cache issue.
Question is can I find how the calls to the tts service are done with the Home page entity icon…and if so how? automations.yaml below. Thanks Rudi.
- id: '1626864776582'
alias: Garage door open
description: ''
trigger:
- platform: state
entity_id: binary_sensor.garage_test_in
from: 'off'
to: 'on'
condition: []
action:
- service: tts.google_translate_say
data:
message: Garage door open
mode: single
- id: '1626866074373'
alias: Garage door closed
description: ''
trigger:
- platform: state
entity_id: binary_sensor.garage_test_in
from: 'on'
to: 'off'
condition: []
action:
- service: tts.google_translate_say
data:
message: Garage door closed
mode: single
Hello!
First thing first, can you go to Developer Tools → Services (tabs) → Type tts.google_translate_say
. Can you confirm that the services existed there?
In addition, it appears you have not chosen a target entity for google to speak.
Lastly, can you tell me what version of Home Assistant are you currently running? If you are using version 2021.7, you may even be able to combine those 2 automations.
Yep got it added target entity to both and and works. Sorry first automation! Thanks
message: Garage door open
entity_id: media_player.kitchen
Good Welcome to Home Assistant.
Anyway, if you have 2021.7 version, you can try the following YAML code-
alias: Garage Door Opened/Closed Notification
description: ''
mode: single
trigger:
- platform: state
entity_id: binary_sensor.garage_test_in
to: 'on'
id: Opened
- platform: state
entity_id: binary_sensor.garage_test_in
to: 'off'
id: Closed
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: Opened
sequence:
- service: tts.google_translate_say
data:
entity_id: media_player.kitchen
message: Garage Door Opened
- conditions:
- condition: trigger
id: Closed
sequence:
- service: tts.google_translate_say
data:
entity_id: media_player.kitchen
message: Garage Door Closed
default: []
In 2021.7 version, you can take advantage of the new features - so called trigger condition
and trigger ID
to be specified in the choose
action - therefore allowing you to merge 2 automation into single automation.
1 Like
Why so complicated?
- id: '1626866074373'
alias: Garage door notification
trigger:
- platform: state
entity_id: binary_sensor.garage_test_in
action:
- service: tts.google_translate_say
data:
entity_id: media_player.kitchen
message: >
Garage door {{'opened' if trigger.to_state.state == 'on' else 'closed'}}
mode: single
1 Like