Skip to content

Commit

Permalink
Merge pull request #15 from dm82m/master
Browse files Browse the repository at this point in the history
differentiating between state_class measurement and total_increasing
  • Loading branch information
erikkastelec authored Sep 9, 2021
2 parents 3e2a10f + 1f0e410 commit df78005
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/wemportal/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import async_timeout
import homeassistant.helpers.config_validation as config_validation
import voluptuous as vol
from homeassistant.components.sensor import SensorEntity, PLATFORM_SCHEMA, STATE_CLASS_MEASUREMENT
from homeassistant.components.sensor import SensorEntity, PLATFORM_SCHEMA, STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING
from homeassistant.const import (
CONF_USERNAME,
CONF_PASSWORD,
Expand Down Expand Up @@ -180,8 +180,10 @@ def device_class(self):
@property
def state_class(self):
"""Return the state class of this entity, if any."""
if self._unit == '°C' or self._unit == 'kWh' or self._unit == 'Wh' or self._unit == 'kW' or self._unit == 'W' or self._unit == '%':
if self._unit == '°C' or self._unit == 'kW' or self._unit == 'W' or self._unit == '%':
return STATE_CLASS_MEASUREMENT
elif self._unit == 'kWh' or self._unit == 'Wh':
return STATE_CLASS_TOTAL_INCREASING
else:
return None

Expand Down

0 comments on commit df78005

Please sign in to comment.