Move temperature conversions to sensor base class (5/8) (#54475)
This commit is contained in:
parent
e55868b17f
commit
103e21c278
65 changed files with 289 additions and 288 deletions
|
@ -62,7 +62,7 @@ class PlexSensor(SensorEntity):
|
|||
self._attr_name = NAME_FORMAT.format(plex_server.friendly_name)
|
||||
self._attr_should_poll = False
|
||||
self._attr_unique_id = f"sensor-{plex_server.machine_identifier}"
|
||||
self._attr_unit_of_measurement = "Watching"
|
||||
self._attr_native_unit_of_measurement = "Watching"
|
||||
|
||||
self._server = plex_server
|
||||
self.async_refresh_sensor = Debouncer(
|
||||
|
@ -87,7 +87,7 @@ class PlexSensor(SensorEntity):
|
|||
async def _async_refresh_sensor(self):
|
||||
"""Set instance object and trigger an entity state update."""
|
||||
_LOGGER.debug("Refreshing sensor [%s]", self.unique_id)
|
||||
self._attr_state = len(self._server.sensor_attributes)
|
||||
self._attr_native_value = len(self._server.sensor_attributes)
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
|
@ -128,7 +128,7 @@ class PlexLibrarySectionSensor(SensorEntity):
|
|||
self._attr_name = f"{self.server_name} Library - {plex_library_section.title}"
|
||||
self._attr_should_poll = False
|
||||
self._attr_unique_id = f"library-{self.server_id}-{plex_library_section.uuid}"
|
||||
self._attr_unit_of_measurement = "Items"
|
||||
self._attr_native_unit_of_measurement = "Items"
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Run when about to be added to hass."""
|
||||
|
@ -164,7 +164,7 @@ class PlexLibrarySectionSensor(SensorEntity):
|
|||
self.library_type, self.library_type
|
||||
)
|
||||
|
||||
self._attr_state = self.library_section.totalViewSize(
|
||||
self._attr_native_value = self.library_section.totalViewSize(
|
||||
libtype=primary_libtype, includeCollections=False
|
||||
)
|
||||
for libtype in LIBRARY_ATTRIBUTE_TYPES.get(self.library_type, []):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue