Skip to content

Commit c08ee47

Browse files
authored
Merge pull request #239 from jaroschek/feature/missing-state-class
Add missing state class
2 parents 5d4aea5 + 177760e commit c08ee47

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

custom_components/myuplink/sensor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ def _update_from_parameter(self, parameter: Parameter) -> None:
108108
self._attr_state_class = SensorStateClass.TOTAL
109109
elif self._parameter.unit == UnitOfFrequency.HERTZ:
110110
self._attr_device_class = SensorDeviceClass.FREQUENCY
111+
self._attr_state_class = SensorStateClass.MEASUREMENT
111112
elif self._parameter.unit in (UnitOfPower.KILO_WATT, UnitOfPower.WATT):
112113
self._attr_device_class = SensorDeviceClass.POWER
114+
self._attr_state_class = SensorStateClass.MEASUREMENT
113115
elif self._parameter.unit in (
114116
UnitOfTime.DAYS,
115117
UnitOfTime.HOURS,
@@ -122,6 +124,7 @@ def _update_from_parameter(self, parameter: Parameter) -> None:
122124
self._attr_device_class = SensorDeviceClass.DURATION
123125
elif self._parameter.unit == CustomUnits.POWER_WS:
124126
self._attr_device_class = SensorDeviceClass.POWER
127+
self._attr_state_class = SensorStateClass.MEASUREMENT
125128
self._attr_native_unit_of_measurement = UnitOfPower.WATT
126129
elif self._parameter.unit == CustomUnits.DEGREE_MINUTES:
127130
self._attr_device_class = "degree_minutes"

0 commit comments

Comments
 (0)