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

@ -33,21 +33,13 @@ class SonosPowerEntity(SonosEntity, BinarySensorEntity):
"""Representation of a Sonos power entity."""
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
_attr_device_class = DEVICE_CLASS_BATTERY_CHARGING
@property
def unique_id(self) -> str:
"""Return the unique ID of the sensor."""
return f"{self.soco.uid}-power"
@property
def name(self) -> str:
"""Return the name of the sensor."""
return f"{self.speaker.zone_name} Power"
@property
def device_class(self) -> str:
"""Return the entity's device class."""
return DEVICE_CLASS_BATTERY_CHARGING
def __init__(self, speaker: SonosSpeaker) -> None:
"""Initialize the power entity binary sensor."""
super().__init__(speaker)
self._attr_unique_id = f"{self.soco.uid}-power"
self._attr_name = f"{self.speaker.zone_name} Power"
async def _async_poll(self) -> None:
"""Poll the device for the current state."""