B5r1oJ0A9G / teufel_raumfeld

Integration for Teufel smart speaker (aka Raumfeld Multiroom) into https://www.home-assistant.io/.
GNU General Public License v3.0
31 stars 7 forks source link

UnboundLocalError: local variable 'play_uri' referenced before assignment #38

Closed kalbfuss closed 1 year ago

kalbfuss commented 2 years ago

I can no longer use the TTS service with my Teufel Raumfeld speakers (neither cloud-based nor via Google Translate). TTS stopped working a while ago. I do not exactly know when it broke. This is my test script:

alias: Liebeserklärung
sequence:
  - service: tts.cloud_say
    data:
      message: >-
        Guten Morgen Joël und Isabelle. Auch wenn der Papa nicht zu Hause ist,
        denkt er an euch und hat euch lieb.
      entity_id: media_player.room_cinebar_lux
mode: single

And here are the error messages from the log:

Logger: custom_components.teufel_raumfeld
Source: custom_components/teufel_raumfeld/__init__.py:106
Integration: Teufel Raumfeld ([documentation](https://github.com/B5r1oJ0A9G/teufel_raumfeld/wiki), [issues](https://github.com/B5r1oJ0A9G/teufel_raumfeld/issues))
First occurred: 9:53:51 PM (7 occurrences)
Last logged: 10:02:34 PM
Unexpected URI for media type: music
Logger: homeassistant.components.script.1662148356947
Source: custom_components/teufel_raumfeld/media_player.py:462
Integration: Script (documentation, issues)
First occurred: 9:53:56 PM (6 occurrences)
Last logged: 10:02:34 PM

Liebeserklärung (Duplicate): Error executing script. Unexpected error for call_service at pos 1: local variable 'play_uri' referenced before assignment
Liebeserklärung (Duplicate): Error executing script. Unexpected error for call_service at pos 2: local variable 'play_uri' referenced before assignment
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 447, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 680, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1713, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 218, in async_say_handle
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1713, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 676, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 930, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 713, in _handle_entity_call
    await result
  File "/config/custom_components/teufel_raumfeld/media_player.py", line 462, in async_play_media
    log_debug("self._rooms=%s, play_uri=%s" % (self._rooms, play_uri))
UnboundLocalError: local variable 'play_uri' referenced before assignment
Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/teufel_raumfeld/media_player.py:462
Integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 9:53:56 PM (7 occurrences)
Last logged: 10:02:34 PM
[548195573024] local variable 'play_uri' referenced before assignment

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 199, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1713, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 290, in service_handler
    await script_entity.async_turn_on(
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 398, in async_turn_on
    await coro
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 428, in _async_run
    return await self.script.async_run(script_vars, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1513, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 405, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 449, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 472, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 447, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 680, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1713, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 218, in async_say_handle
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1713, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 676, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 930, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 713, in _handle_entity_call
    await result
  File "/config/custom_components/teufel_raumfeld/media_player.py", line 462, in async_play_media
    log_debug("self._rooms=%s, play_uri=%s" % (self._rooms, play_uri))
UnboundLocalError: local variable 'play_uri' referenced before assignment

Noteworthy the same script works with a Sonos speaker. I am running Teufel Raumfeld v0.1.12-alpha4 on Home Assistant version 2022.8.7

B5r1oJ0A9G commented 1 year ago

This issue should be fixed now with the release of version 0.1.12-alpha6.

The credits for fixing this goes to @Alex9779.

B5r1oJ0A9G commented 1 year ago

Released in v0.1.13-alpha1.

kalbfuss commented 1 year ago

I confirm that TTS works again. Thanks for fixing!

B5r1oJ0A9G commented 1 year ago

Thank you very much for the feedback @kalbfuss!