I’m trying to make Hassio speak using google tts and mopidy, but sometimes (40% probability for success launch without changing of config or rebooting Hassio) I’m getting an error when I’m calling it.
Raspberry 4 2GB
Got unexpected return value: ‘repeat: 0, random: 0, single: 0, consume: 0, playlist: 196, playlistlength: 1, xfade: 0, state: stop, nextsong: 0, nextsongid: 292’
or
Unexpected error for call_service at pos 3: Got unexpected return value: ‘Id: 289’
or it can show an error, but play the sound correctly:
Full error
Logger: homeassistant.core
Source: components/mpd/media_player.py:169
First occurred: 9:00:15 (1947 occurrences)
Last logged: 15:04:15
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
state = self.state
File "/usr/src/homeassistant/homeassistant/components/mpd/media_player.py", line 169, in state
if self._status["state"] == "play":
KeyError: 'state'
Google tts is working ok - there are cached audio files and I can play them correctly
here is one of the scripts
tts_weather:
sequence:
service: tts.google_say
entity_id: media_player.mpd
data_template:
message: >-
На улице {{ states("sensor.narodmon_temperature") | round(0) }} градусов {% if states("sensor.narodmon_temperature") > "1" -%} тепла
{%- else -%}
{%- endif %}. Днем ожидается до {{ states("sensor.dark_sky_daytime_high_temperature_0d") | round(0) }} градусов, ночью температура может опуститься до {{ states("sensor.dark_sky_overnight_low_temperature_0d") | round(0) }} градусов,
{{ states("sensor.dark_sky_summary_0d") }} Вероятность осадков сегодня {{ states("sensor.dark_sky_precip_probability_0d") | round(0) }} процентов
here are last logs of it
full error log
Logger: homeassistant.components.automation
Source: components/mpd/media_player.py:351
Integration: Автоматизация (documentation, issues)
First occurred: 9:00:13 (1 occurrences)
Last logged: 9:00:13
tts test start 09-00: Error executing script. Unexpected error for call_service at pos 3: Got unexpected return value: ‘Id: 289’
Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 138, in _async_step self, f"async{cv.determine_script_action(self._action)}_step" File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 233, in _async_call_service_step context=self._context, File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 101, in async_call_from_config domain, service_name, service_data, blocking=blocking, context=context File “/usr/src/homeassistant/homeassistant/core.py”, line 1234, in async_call await asyncio.shield(self._execute_service(handler, service_call)) File “/usr/src/homeassistant/homeassistant/core.py”, line 1257, in _execute_service await handler.func(service_call) File “/usr/src/homeassistant/homeassistant/components/script/init.py”, line 207, in service_handler await script.async_turn_on(variables=service.data, context=service.context) File “/usr/src/homeassistant/homeassistant/components/script/init.py”, line 284, in async_turn_on await self.script.async_run(kwargs.get(ATTR_VARIABLES), context) File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 693, in async_run await run.async_run() File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 444, in async_run await self._async_run() File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 460, in _async_run await self._async_step(not propagate_exceptions) File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 138, in _async_step self, f"async{cv.determine_script_action(self._action)}_step" File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 233, in _async_call_service_step context=self._context, File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 101, in async_call_from_config domain, service_name, service_data, blocking=blocking, context=context File “/usr/src/homeassistant/homeassistant/core.py”, line 1234, in async_call await asyncio.shield(self._execute_service(handler, service_call)) File “/usr/src/homeassistant/homeassistant/core.py”, line 1257, in _execute_service await handler.func(service_call) File “/usr/src/homeassistant/homeassistant/components/tts/init.py”, line 172, in async_say_handle DOMAIN_MP, SERVICE_PLAY_MEDIA, data, blocking=True File “/usr/src/homeassistant/homeassistant/core.py”, line 1234, in async_call await asyncio.shield(self._execute_service(handler, service_call)) File “/usr/src/homeassistant/homeassistant/core.py”, line 1257, in _execute_service await handler.func(service_call) File “/usr/src/homeassistant/homeassistant/helpers/entity_component.py”, line 198, in handle_service self._platforms.values(), func, call, required_features File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 402, in entity_service_call future.result() # pop exception if have File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 599, in async_request_call await coro File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 433, in _handle_entity_call await result File “/usr/src/homeassistant/homeassistant/components/media_player/init.py”, line 599, in async_play_media ft.partial(self.play_media, media_type, media_id, **kwargs) File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run result = self.fn(*self.args, **self.kwargs) File “/usr/src/homeassistant/homeassistant/components/mpd/media_player.py”, line 351, in play_media self._client.clear() File “/usr/local/lib/python3.7/site-packages/mpd/base.py”, line 381, in mpd_command return wrapper(self, name, args, callback) File “/usr/local/lib/python3.7/site-packages/mpd/base.py”, line 473, in _execute return retval() File “/usr/local/lib/python3.7/site-packages/mpd/base.py”, line 368, in command_callback res = function(self, self._read_lines()) File “/usr/local/lib/python3.7/site-packages/mpd/base.py”, line 313, in _parse_nothing “Got unexpected return value: ‘{}’”.format(', '.join(lines))) mpd.base.ProtocolError: Got unexpected return value: ‘Id: 289’
I thought there is too much variables, but there is another config and it is working sometimes also
script code
tts_date_time:
sequence:
service: tts.google_say
entity_id: media_player.mpd
data_template:
message: >-
{% if (now().month == 1) -%}
{% set month = "января" %}
{% elif (now().month == 2) -%}
{% set month = "февраля" %}
{% elif (now().month == 3) -%}
{% set month = "Марта" %}
{% elif (now().month == 4) -%}
{% set month = "Апреля" %}
{% elif (now().month == 5) -%}
{% set month = "Мая" %}
{% elif (now().month == 6) -%}
{% set month = "Июня" %}
{% elif (now().month == 7) -%}
{% set month = "Июля" %}
{% elif (now().month == 8) -%}
{% set month = "Августа" %}
{% elif (now().month == 9) -%}
{% set month = "Сентября" %}
{% elif (now().month == 10) -%}
{% set month = "Октября" %}
{% elif (now().month == 11) -%}
{% set month = "Ноября" %}
{% elif (now().month == 12) -%}
{% set month = "Декабря" %}
{%- else -%}
{%- endif %}
{% if (now().isoweekday() == 1) -%}
{% set weekday = "понедельник" %}
{% elif (now().isoweekday() == 2) -%}
{% set weekday = "вторник" %}
{% elif (now().isoweekday() == 3) -%}
{% set weekday = "среда" %}
{% elif (now().isoweekday() == 4) -%}
{% set weekday = "четверг" %}
{% elif (now().isoweekday() == 5) -%}
{% set weekday = "пятница" %}
{% elif (now().isoweekday() == 6) -%}
{% set weekday = "суббота" %}
{% elif (now().isoweekday() == 7) -%}
{% set weekday = "воскресенье" %}
{%- else -%}
{%- endif %}
{% if (now().hour > 4) and (now().hour < 11) -%}
Доброе утро
{% elif (now().hour > 11) and (now().hour <= 16) -%}
Добрый день
{% elif (now().hour > 16) and (now().hour <= 21) -%}
Добрый вечер
{%- else -%}
Доброй ночи
{%- endif %}, сейчас {{ weekday }} {{ now().day }} {{ month }}. {{ now().hour }} часов {{ now().minute }} минут
google say config
tts:
- platform: google_translate
language: 'ru'
cache: true
cache_dir: /share/tts
time_memory: 300
base_url: https://***.com:8123
service_name: google_say
Maybe Mopidy isn’t waiting for necessary time and is looking for audio file before it is downloaded?