Collection of changing entity properties to class attributes - 2 (#51345)

This commit is contained in:
Franck Nijhof 2021-06-01 21:43:55 +02:00 committed by GitHub
parent e5dff49440
commit fcdd8b11a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 70 additions and 215 deletions

View file

@ -25,6 +25,9 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
class LightwaveBattery(SensorEntity):
"""Lightwave TRV Battery."""
_attr_device_class = DEVICE_CLASS_BATTERY
_attr_unit_of_measurement = PERCENTAGE
def __init__(self, name, lwlink, serial):
"""Initialize the Lightwave Trv battery sensor."""
self._name = name
@ -32,11 +35,6 @@ class LightwaveBattery(SensorEntity):
self._lwlink = lwlink
self._serial = serial
@property
def device_class(self):
"""Return the device class of the sensor."""
return DEVICE_CLASS_BATTERY
@property
def name(self):
"""Return the name of the sensor."""
@ -47,11 +45,6 @@ class LightwaveBattery(SensorEntity):
"""Return the state of the sensor."""
return self._state
@property
def unit_of_measurement(self):
"""Return the state of the sensor."""
return PERCENTAGE
def update(self):
"""Communicate with a Lightwave RTF Proxy to get state."""
(dummy_temp, dummy_targ, battery, dummy_output) = self._lwlink.read_trv_status(