mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Correct sensor state attribute and device class in Velbus sensors (#102099)
This commit is contained in:
parent
79811e3cd9
commit
4913e7e846
@ -45,25 +45,18 @@ class VelbusSensor(VelbusEntity, SensorEntity):
|
|||||||
"""Initialize a sensor Velbus entity."""
|
"""Initialize a sensor Velbus entity."""
|
||||||
super().__init__(channel)
|
super().__init__(channel)
|
||||||
self._is_counter: bool = counter
|
self._is_counter: bool = counter
|
||||||
# define the unique id
|
|
||||||
if self._is_counter:
|
if self._is_counter:
|
||||||
self._attr_unique_id = f"{self._attr_unique_id}-counter"
|
|
||||||
# define the name
|
|
||||||
if self._is_counter:
|
|
||||||
self._attr_name = f"{self._attr_name}-counter"
|
|
||||||
# define the device class
|
|
||||||
if self._is_counter:
|
|
||||||
self._attr_device_class = SensorDeviceClass.POWER
|
|
||||||
elif channel.is_counter_channel():
|
|
||||||
self._attr_device_class = SensorDeviceClass.ENERGY
|
self._attr_device_class = SensorDeviceClass.ENERGY
|
||||||
|
self._attr_icon = "mdi:counter"
|
||||||
|
self._attr_name = f"{self._attr_name}-counter"
|
||||||
|
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||||
|
self._attr_unique_id = f"{self._attr_unique_id}-counter"
|
||||||
|
elif channel.is_counter_channel():
|
||||||
|
self._attr_device_class = SensorDeviceClass.POWER
|
||||||
|
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
elif channel.is_temperature():
|
elif channel.is_temperature():
|
||||||
self._attr_device_class = SensorDeviceClass.TEMPERATURE
|
self._attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||||
# define the icon
|
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
if self._is_counter:
|
|
||||||
self._attr_icon = "mdi:counter"
|
|
||||||
# the state class
|
|
||||||
if self._is_counter:
|
|
||||||
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
|
|
||||||
else:
|
else:
|
||||||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
# unit
|
# unit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user