Skip to content

Commit

Permalink
fix: handle deprecation of device_state_attributes
Browse files Browse the repository at this point in the history
Swap to extra_state_attributes
  • Loading branch information
alandtse committed Nov 22, 2021
1 parent 1b2b890 commit c224ee4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion custom_components/alexa_media/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,6 @@ def assumed_state(self) -> bool:
return not last_refresh_success

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
return self._attrs
2 changes: 1 addition & 1 deletion custom_components/alexa_media/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ async def async_play_media(self, media_type, media_id, enqueue=None, **kwargs):
await self.async_update()

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
attr = {
"available": self.available,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/alexa_media/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def targets(self):
for _, entity in account_dict["entities"]["media_player"].items():
entity_name = (entity.entity_id).split(".")[1]
devices[entity_name] = entity.unique_id
if self.last_called and entity.device_state_attributes.get(
if self.last_called and entity.extra_state_attributes.get(
"last_called"
):
entity_name_last_called = (
Expand Down
6 changes: 3 additions & 3 deletions custom_components/alexa_media/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def recurrence(self):
)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return additional attributes."""
import json

Expand Down Expand Up @@ -638,8 +638,8 @@ def reminder(self):
return self._next["reminderLabel"] if self._next else None

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the scene state attributes."""
attr = super().device_state_attributes
attr = super().extra_state_attributes
attr.update({"reminder": self.reminder})
return attr

0 comments on commit c224ee4

Please sign in to comment.