mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +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."""
|
||||
super().__init__(channel)
|
||||
self._is_counter: bool = counter
|
||||
# define the unique id
|
||||
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_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():
|
||||
self._attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||
# define the icon
|
||||
if self._is_counter:
|
||||
self._attr_icon = "mdi:counter"
|
||||
# the state class
|
||||
if self._is_counter:
|
||||
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||
else:
|
||||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||
# unit
|
||||
|
Loading…
x
Reference in New Issue
Block a user