diff --git a/custom_components/sonos_cloud/media_player.py b/custom_components/sonos_cloud/media_player.py index 0f9d1db..13995d3 100644 --- a/custom_components/sonos_cloud/media_player.py +++ b/custom_components/sonos_cloud/media_player.py @@ -53,8 +53,13 @@ def __init__(self, player: dict[str, Any]): async def async_added_to_hass(self): """Complete entity setup.""" await super().async_added_to_hass() + await self.async_restore_states() + + async def async_restore_states(self) -> None: + """Restore last entity state.""" + if (last_state := await self.async_get_last_state()) is None: + return - last_state = await self.async_get_last_state() if volume := last_state.attributes.get("volume_level"): self._attr_volume_level = volume