Use _attrs where possible in Sonos (#60931)

This commit is contained in:
jjlawren 2021-12-03 12:57:19 -06:00 committed by GitHub
parent ba99dc3af9
commit 171b57bf32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 74 deletions

View file

@ -39,18 +39,10 @@ class SonosLevelEntity(SonosEntity, NumberEntity):
def __init__(self, speaker: SonosSpeaker, level_type: str) -> None:
"""Initialize the level entity."""
super().__init__(speaker)
self._attr_unique_id = f"{self.soco.uid}-{level_type}"
self._attr_name = f"{self.speaker.zone_name} {level_type.capitalize()}"
self.level_type = level_type
@property
def unique_id(self) -> str:
"""Return the unique ID."""
return f"{self.soco.uid}-{self.level_type}"
@property
def name(self) -> str:
"""Return the name."""
return f"{self.speaker.zone_name} {self.level_type.capitalize()}"
async def _async_poll(self) -> None:
"""Poll the value if subscriptions are not working."""
# Handled by SonosSpeaker