diff --git a/homeassistant/components/russound_rio/entity.py b/homeassistant/components/russound_rio/entity.py index 4d458118939..292e14e3d6d 100644 --- a/homeassistant/components/russound_rio/entity.py +++ b/homeassistant/components/russound_rio/entity.py @@ -43,7 +43,7 @@ class RussoundBaseEntity(Entity): controller: Controller, ) -> None: """Initialize the entity.""" - self._instance = controller.instance + self._client = controller.client self._controller = controller self._primary_mac_address = ( controller.mac_address or controller.parent_controller.mac_address @@ -60,9 +60,9 @@ class RussoundBaseEntity(Entity): model=controller.controller_type, sw_version=controller.firmware_version, ) - if isinstance(self._instance.connection_handler, RussoundTcpConnectionHandler): + if isinstance(self._client.connection_handler, RussoundTcpConnectionHandler): self._attr_device_info["configuration_url"] = ( - f"http://{self._instance.connection_handler.host}" + f"http://{self._client.connection_handler.host}" ) if controller.parent_controller: self._attr_device_info["via_device"] = ( @@ -82,12 +82,12 @@ class RussoundBaseEntity(Entity): async def async_added_to_hass(self) -> None: """Register callbacks.""" - self._instance.connection_handler.add_connection_callback( + self._client.connection_handler.add_connection_callback( self._is_connected_updated ) async def async_will_remove_from_hass(self) -> None: """Remove callbacks.""" - self._instance.connection_handler.remove_connection_callback( + self._client.connection_handler.remove_connection_callback( self._is_connected_updated ) diff --git a/homeassistant/components/russound_rio/manifest.json b/homeassistant/components/russound_rio/manifest.json index 0a18bdb3b8a..55b88c33c45 100644 --- a/homeassistant/components/russound_rio/manifest.json +++ b/homeassistant/components/russound_rio/manifest.json @@ -7,5 +7,5 @@ "iot_class": "local_push", "loggers": ["aiorussound"], "quality_scale": "silver", - "requirements": ["aiorussound==3.0.5"] + "requirements": ["aiorussound==3.1.5"] } diff --git a/homeassistant/components/russound_rio/media_player.py b/homeassistant/components/russound_rio/media_player.py index a5bb392a028..2a2b951cf2b 100644 --- a/homeassistant/components/russound_rio/media_player.py +++ b/homeassistant/components/russound_rio/media_player.py @@ -4,7 +4,8 @@ from __future__ import annotations import logging -from aiorussound import Source, Zone +from aiorussound import RussoundClient, Source, Zone +from aiorussound.models import CallbackType from homeassistant.components.media_player import ( MediaPlayerDeviceClass, @@ -130,25 +131,26 @@ class RussoundZoneDevice(RussoundBaseEntity, MediaPlayerEntity): self._attr_name = zone.name self._attr_unique_id = f"{self._primary_mac_address}-{zone.device_str()}" for flag, feature in MP_FEATURES_BY_FLAG.items(): - if flag in zone.instance.supported_features: + if flag in zone.client.supported_features: self._attr_supported_features |= feature - def _callback_handler(self, device_str, *args): - if ( - device_str == self._zone.device_str() - or device_str == self._current_source().device_str() - ): - self.schedule_update_ha_state() + async def _state_update_callback( + self, _client: RussoundClient, _callback_type: CallbackType + ) -> None: + """Call when the device is notified of changes.""" + self.async_write_ha_state() async def async_added_to_hass(self) -> None: """Register callback handlers.""" await super().async_added_to_hass() - self._zone.add_callback(self._callback_handler) + await self._client.register_state_update_callbacks(self._state_update_callback) async def async_will_remove_from_hass(self) -> None: """Remove callbacks.""" await super().async_will_remove_from_hass() - self._zone.remove_callback(self._callback_handler) + await self._client.unregister_state_update_callbacks( + self._state_update_callback + ) def _current_source(self) -> Source: return self._zone.fetch_current_source() diff --git a/requirements_all.txt b/requirements_all.txt index 03a76744ec1..8f46fb0203d 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -356,7 +356,7 @@ aioridwell==2024.01.0 aioruckus==0.41 # homeassistant.components.russound_rio -aiorussound==3.0.5 +aiorussound==3.1.5 # homeassistant.components.ruuvi_gateway aioruuvigateway==0.1.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 0d1815481a9..0e7dd29c64c 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -338,7 +338,7 @@ aioridwell==2024.01.0 aioruckus==0.41 # homeassistant.components.russound_rio -aiorussound==3.0.5 +aiorussound==3.1.5 # homeassistant.components.ruuvi_gateway aioruuvigateway==0.1.0