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:
parent
fcb8ab23ab
commit
c43bdbf7c8
2 changed files with 4 additions and 1 deletions
|
@ -42,6 +42,7 @@ class LightwaveTrv(ClimateEntity):
|
||||||
self._hvac_action = None
|
self._hvac_action = None
|
||||||
self._lwlink = lwlink
|
self._lwlink = lwlink
|
||||||
self._serial = serial
|
self._serial = serial
|
||||||
|
self._attr_unique_id = f"{serial}-trv"
|
||||||
# inhibit is used to prevent race condition on update. If non zero, skip next update cycle.
|
# inhibit is used to prevent race condition on update. If non zero, skip next update cycle.
|
||||||
self._inhibit = 0
|
self._inhibit = 0
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"""Support for LightwaveRF TRV - Associated Battery."""
|
"""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 homeassistant.const import CONF_NAME, DEVICE_CLASS_BATTERY, PERCENTAGE
|
||||||
|
|
||||||
from . import CONF_SERIAL, LIGHTWAVE_LINK
|
from . import CONF_SERIAL, LIGHTWAVE_LINK
|
||||||
|
@ -27,6 +27,7 @@ class LightwaveBattery(SensorEntity):
|
||||||
|
|
||||||
_attr_device_class = DEVICE_CLASS_BATTERY
|
_attr_device_class = DEVICE_CLASS_BATTERY
|
||||||
_attr_unit_of_measurement = PERCENTAGE
|
_attr_unit_of_measurement = PERCENTAGE
|
||||||
|
_attr_state_class = STATE_CLASS_MEASUREMENT
|
||||||
|
|
||||||
def __init__(self, name, lwlink, serial):
|
def __init__(self, name, lwlink, serial):
|
||||||
"""Initialize the Lightwave Trv battery sensor."""
|
"""Initialize the Lightwave Trv battery sensor."""
|
||||||
|
@ -34,6 +35,7 @@ class LightwaveBattery(SensorEntity):
|
||||||
self._state = None
|
self._state = None
|
||||||
self._lwlink = lwlink
|
self._lwlink = lwlink
|
||||||
self._serial = serial
|
self._serial = serial
|
||||||
|
self._attr_unique_id = f"{serial}-trv-battery"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue