Add lightwave state_class and unique_id properties (#51544)

* Add state_class and unique_id properties

* Update homeassistant/components/lightwave/sensor.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* fix isort

* set class via attribute

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Colin Robbins 2021-06-06 19:10:16 +01:00 committed by GitHub
parent fcb8ab23ab
commit c43bdbf7c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -1,5 +1,5 @@
"""Support for LightwaveRF TRV - Associated Battery."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity
from homeassistant.const import CONF_NAME, DEVICE_CLASS_BATTERY, PERCENTAGE
from . import CONF_SERIAL, LIGHTWAVE_LINK
@ -27,6 +27,7 @@ class LightwaveBattery(SensorEntity):
_attr_device_class = DEVICE_CLASS_BATTERY
_attr_unit_of_measurement = PERCENTAGE
_attr_state_class = STATE_CLASS_MEASUREMENT
def __init__(self, name, lwlink, serial):
"""Initialize the Lightwave Trv battery sensor."""
@ -34,6 +35,7 @@ class LightwaveBattery(SensorEntity):
self._state = None
self._lwlink = lwlink
self._serial = serial
self._attr_unique_id = f"{serial}-trv-battery"
@property
def name(self):