TTS.Google_translate_say seems not to accept data_template

Hello,
I’ve been lately trying to get the info from a simple DHT22 sensor and send an service call in order to play the value of the temperature through my speakers.
Following docs and similar topics, I’ve created and script:

  alias: Testing
  sequence:
    - service: tts.google_translate_say
      entity_id: media_player.symfonisk
      data_template:
        message: "La temperatura del salon es {{ states('sensor.temperatura_salon') }} grados."
        cache: false

But it doesn’t work, as far as I always get the same error.
extra keys not allowed @ data['data_template']

Where I’m getting lost?

Doesn’t look like you added the script name, you only added the friendly name for the script (alias). Should look something like this:

  test_script:
    alias: Testing
    sequence:
      ...

Change test_script: to whatever you want. Only lowercase letters, underscores, and/or numbers. The resulting entity ID for the script would be script.test_script in this case.

1 Like

I’ve have modified the code on scripts.yaml file, and now the script doesn’t appears on the configuration->scripts section of the front end.
How can I test if it’s running?

Forget about this: through Services :sweat_smile::sweat_smile:

Thank you very much, Tediore.
I was missing just that

No prob! Glad it helped.

hello, since the last update of home assistant 117.5 the tts google say stopped working with data_template. I get an error when calling the service. does anybody know how I can fix it?

Logger: homeassistant.components.websocket_api.http.connection.1781932744
Source: core.py:1402
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 22:25:16 (7 occurrences)
Last logged: 22:28:22

extra keys not allowed @ data[‘data_template’]

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 135, in handle_call_service await hass.services.async_call( File “/usr/src/homeassistant/homeassistant/core.py”, line 1402, in async_call processed_data = handler.schema(service_data) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 272, in call return self._compiled([], data) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 594, in validate_dict return base_validate(path, iteritems(data), out) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 432, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: extra keys not allowed @ data[‘data_template’]

Can’t really help you unless you share the error message.

Logger: homeassistant.components.websocket_api.http.connection.1781932744
Source: core.py:1402
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 22:25:16 (7 occurrences)
Last logged: 22:28:22

extra keys not allowed @ data[‘data_template’]

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 135, in handle_call_service await hass.services.async_call( File “/usr/src/homeassistant/homeassistant/core.py”, line 1402, in async_call processed_data = handler.schema(service_data) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 272, in call return self._compiled([], data) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 594, in validate_dict return base_validate(path, iteritems(data), out) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 432, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: extra keys not allowed @ data[‘data_template’]

the error is random

Are you calling this from developer tools > services or in an automation/script?

Post your config, I don’t think you have the correct format. The error is stating that you can’t put data_template inside data, which is true. You can’t do that. So please, post your config.

of the 3 ways. from developer tools it always gives me error, from script and automation it is random

tts:
  - platform: google_translate
    language: 'es'
    cache: true
    cache_dir: /tmp/tts
    time_memory: 300
    base_url: https://XXXXXX.duckdns.org:8123
    service_name: google_translate_say  

That’s one of the issues then. The service data field at developer tools > services is the data: field, so you can’t put data_template: there (which is what that error is saying). Need to see the error when you try running it from a script/automation (and post the script/automation).

As far as the configuration you posted below, we only need to see your TTS config, not your entire configuration.yaml. Please also format it as code by putting three backticks (```) above and below it.

data_template:
  entity_id: media_player.lobby_music
  message: >-
    Bienvenidos a village de las pampas! {{states ('input_text.abeto')}}. Son
    las {{ states('sensor.hora') }} horas. La temperatura en mar de las pampas
    es {{ states('sensor.mar_de_las_pampas_temperature')|round}} grados. El
    pronostico para hoy dice {{ states('sensor.mar_de_las_pampas_summary_0d')}}.
    Su departamento es Abeto, ubicado en este edificio. A continuación verán en
    las pantallas un video instructivo para llegar a su departamento.  Que
    tengan una feliz estadía!
service: tts.google_translate_say

So when you use that as a service inside an automation, it doesn’t work?

This is what you’d paste into the service caller in the UI. It does not accept templates as @Tediore said.

  entity_id: media_player.lobby_music
  message: >-
    Bienvenidos a village de las pampas!. Son
    las horas. La temperatura en mar de las pampas
    es grados. El
    pronostico para hoy dice .
    Su departamento es Abeto, ubicado en este edificio. A continuación verán en
    las pantallas un video instructivo para llegar a su departamento.  Que
    tengan una feliz estadía!

when i run it from script or automation it sometimes works and sometimes it doesn’t. This error happens with template messages, simple messages always work.
Later when I return home, I copy the error that I get and share it.
Thanks for your help!

these are the errors that I get

Logger: homeassistant.components.tts
Source: components/tts/init.py:172
Integration: Text-to-Speech (TTS) (documentation, issues)
First occurred: 10:47:46 (3 occurrences)
Last logged: 18:29:59

  • Error on init TTS: No TTS from google_translate for ‘Buenos días Popy!. Son las 10:47 horas. Hoy es Martes 10th de Noviembre. El día está Parcialmente Nublado con una temperatura de 20 grados. El pronóstico para hoy dice Parcialmente nublado durante el día, con una temperatura máxima de 21 grados. Hoy tenemos huespedes alojados en el edificio MAR Y ARENAS. La temperatura de la piscina es de 18coma8 grados. Escondé todo el escabio que volvió Sandra! Que tengas un espectacular día! .’
  • Error on init TTS: No TTS from google_translate for ‘Bienvenidos a village de las pampas! Batman y Robin. Son las 18:28 horas. La temperatura en mar de las pampas es 18 grados. El pronostico para hoy dice Parcialmente nublado durante el día… Su departamento es Abeto, ubicado en este edificio. A continuación verán en las pantallas un video instructivo para llegar a su departamento. Que tengan una feliz estadía!’
  • Error on init TTS: No TTS from google_translate for ‘Bienvenidos a village de las pampas! Batman y Robin. Son las 18:29 horas. La temperatura en mar de las pampas es 18 grados. El pronostico para hoy dice Parcialmente nublado durante el día… Su departamento es Abeto, ubicado en este edificio. A continuación verán en las pantallas un video instructivo para llegar a su departamento. Que tengan una feliz estadía!’

Logger: homeassistant.components.google_translate.tts
Source: components/google_translate/tts.py:132
Integration: google_translate (documentation, issues)
First occurred: 10:47:46 (3 occurrences)
Last logged: 18:29:59

Unable to find token seed! Did https://translate.google.com change?

Logger: homeassistant.components.websocket_api.http.connection.1716713288
Source: components/websocket_api/http.py:233
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 10:12:07 (1 occurrences)
Last logged: 10:12:07

Disconnected: Did not receive auth message within 10 seconds.

Logger: homeassistant
Source: custom_components/spotcast/init.py:257
First occurred: 8:00:01 (3 occurrences)
Last logged: 10:00:35

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.8/site-packages/spotipy/client.py”, line 245, in _internal_call
response.raise_for_status()
File “/usr/local/lib/python3.8/site-packages/requests/models.py”, line 941, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/me/player/play?device_id=4444925cf7cff74f53e771e283a2b8f94403a16f

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 1010, in async_run
await asyncio.shield(run.async_run())
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 245, in async_run
await self._async_step(log_exceptions=False)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 253, in _async_step
await getattr(
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 460, in _async_call_service_step
await service_task
File “/usr/src/homeassistant/homeassistant/core.py”, line 1448, in async_call
task.result()
File “/usr/src/homeassistant/homeassistant/core.py”, line 1487, in _execute_service
await self._hass.async_add_executor_job(handler.job.target, service_call)
File “/usr/local/lib/python3.8/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/spotcast/init.py”, line 304, in start_casting
play(client, spotify_device_id, uri, random_song, repeat, shuffle, position)
File “/config/custom_components/spotcast/init.py”, line 257, in play
client.start_playback(**kwargs)
File “/usr/local/lib/python3.8/site-packages/spotipy/client.py”, line 1706, in start_playback
return self._put(
File “/usr/local/lib/python3.8/site-packages/spotipy/client.py”, line 306, in _put
return self._internal_call(“PUT”, url, payload, kwargs)
File “/usr/local/lib/python3.8/site-packages/spotipy/client.py”, line 261, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=4444925cf7cff74f53e771e283a2b8f94403a16f:
Device not found, reason: None

There’s your problem. It’s a bug. You’ll have to wait til there is a fix which is coming in 0.117.6.

with this being the fix