From fe6db04db5e920271c36b15a70a0d5c480fea5c3 Mon Sep 17 00:00:00 2001 From: jjlawren Date: Mon, 2 May 2022 16:24:36 -0500 Subject: [PATCH] Address breaking changes and deprecations in 2022.5 --- custom_components/sonos_cloud/manifest.json | 2 +- custom_components/sonos_cloud/media_player.py | 15 +++++++-------- hacs.json | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/custom_components/sonos_cloud/manifest.json b/custom_components/sonos_cloud/manifest.json index cf37503..5f50d7c 100644 --- a/custom_components/sonos_cloud/manifest.json +++ b/custom_components/sonos_cloud/manifest.json @@ -9,7 +9,7 @@ "zeroconf": [], "homekit": {}, "dependencies": [ - "http" + "auth" ], "after_dependencies": [ "media_source", diff --git a/custom_components/sonos_cloud/media_player.py b/custom_components/sonos_cloud/media_player.py index 0fb01d3..97fb516 100644 --- a/custom_components/sonos_cloud/media_player.py +++ b/custom_components/sonos_cloud/media_player.py @@ -9,14 +9,12 @@ from homeassistant.components.media_player import ( BrowseMedia, MediaPlayerEntity, + MediaPlayerEntityFeature, async_process_play_media_url, ) from homeassistant.components.media_player.const import ( ATTR_MEDIA_EXTRA, MEDIA_CLASS_DIRECTORY, - SUPPORT_BROWSE_MEDIA, - SUPPORT_PLAY_MEDIA, - SUPPORT_VOLUME_SET, ) from homeassistant.components.media_player.errors import BrowseError from homeassistant.components.sonos.const import DOMAIN as SONOS_DOMAIN @@ -51,6 +49,12 @@ async def async_setup_entry( class SonosCloudMediaPlayerEntity(MediaPlayerEntity, RestoreEntity): """Representation of a Sonos Cloud entity.""" + _attr_supported_features = ( + MediaPlayerEntityFeature.BROWSE_MEDIA + | MediaPlayerEntityFeature.PLAY_MEDIA + | MediaPlayerEntityFeature.VOLUME_SET + ) + def __init__(self, player: dict[str, Any]): """Initializle the entity.""" self._attr_name = player["name"] @@ -76,11 +80,6 @@ def state(self) -> str: """Return the state of the entity.""" return STATE_IDLE - @property - def supported_features(self) -> int: - """Flag media player features that are supported.""" - return SUPPORT_BROWSE_MEDIA | SUPPORT_PLAY_MEDIA | SUPPORT_VOLUME_SET - @property def device_info(self) -> DeviceInfo: """Return information about the device.""" diff --git a/hacs.json b/hacs.json index 8019420..615db10 100644 --- a/hacs.json +++ b/hacs.json @@ -2,7 +2,7 @@ "name": "Sonos Cloud", "country": "US", "domains": ["media_player"], - "homeassistant": "2022.3.0", + "homeassistant": "2022.5.0", "render_readme": true, "iot_class": "Cloud Polling" }