B5r1oJ0A9G / teufel_raumfeld

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

Deprecated entities (i.e. `SUPPORT_BROWSE_MEDIA`) have been removed from HA 2024.1, leading to an exception #58

Closed theomega closed 3 weeks ago

theomega commented 6 months ago

When browsing media on a teufel_raumfeld device in HA 2024.1, you get the following error:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1298, in websocket_browse_media
    if MediaPlayerEntityFeature.BROWSE_MEDIA not in player.supported_features:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'int' is not iterable

Reason is that the teufel_raumfeld implementation still returns the old int-based constants for the supported_features method here.

According to the docs, these int contents have been removed in 2024.1, so this is why this error occurs. We are forced to use the MediaPlayerEntityFeature enum according to the docs.

I think what needs to be done is in the media_player.py of this repo here, we need to replace

SUPPORT_RAUMFELD_GROUP = (
    SUPPORT_PAUSE
    | SUPPORT_SEEK
    | SUPPORT_VOLUME_SET
    | SUPPORT_VOLUME_MUTE
    | SUPPORT_PREVIOUS_TRACK
    | SUPPORT_NEXT_TRACK
    | SUPPORT_PLAY_MEDIA
    | SUPPORT_VOLUME_STEP
    | SUPPORT_STOP
    | SUPPORT_TURN_ON
    | SUPPORT_TURN_OFF
    | SUPPORT_PLAY
    | SUPPORT_SHUFFLE_SET
    | SUPPORT_BROWSE_MEDIA
    | SUPPORT_REPEAT_SET
)

with something like

SUPPORT_RAUMFELD_GROUP = (
    MediaPlayerEntityFeature.SUPPORT_PAUSE
    | MediaPlayerEntityFeature.SUPPORT_SEEK
    | MediaPlayerEntityFeature.SUPPORT_VOLUME_SET
    | MediaPlayerEntityFeature.SUPPORT_VOLUME_MUTE
    | MediaPlayerEntityFeature.SUPPORT_PREVIOUS_TRACK
    | MediaPlayerEntityFeature.SUPPORT_NEXT_TRACK
    | MediaPlayerEntityFeature.SUPPORT_PLAY_MEDIA
    | MediaPlayerEntityFeature.SUPPORT_VOLUME_STEP
    | MediaPlayerEntityFeature.SUPPORT_STOP
    | MediaPlayerEntityFeature.SUPPORT_TURN_ON
    | MediaPlayerEntityFeature.SUPPORT_TURN_OFF
    | MediaPlayerEntityFeature.SUPPORT_PLAY
    | MediaPlayerEntityFeature.SUPPORT_SHUFFLE_SET
    | MediaPlayerEntityFeature.SUPPORT_BROWSE_MEDIA
    | MediaPlayerEntityFeature.SUPPORT_REPEAT_SET
)

Similar issues might come up from other constants as all of these integer based constants seem to have been retired.

B5r1oJ0A9G commented 3 weeks ago

Thank you very much @theomega for reporting this. Thanks to @klausw01 the issue seems to be fixed, so we are closing it.