Remove last_reset
attribute and set state class to total_increasing
for saj energy sensors (#54813)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
6aca3b326f
commit
9c7ea786a7
1 changed files with 3 additions and 3 deletions
|
@ -10,6 +10,7 @@ import voluptuous as vol
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
@ -34,7 +35,6 @@ from homeassistant.core import CALLBACK_TYPE, callback
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.event import async_call_later
|
from homeassistant.helpers.event import async_call_later
|
||||||
from homeassistant.util import dt as dt_util
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -177,10 +177,10 @@ class SAJsensor(SensorEntity):
|
||||||
self._serialnumber = serialnumber
|
self._serialnumber = serialnumber
|
||||||
self._state = self._sensor.value
|
self._state = self._sensor.value
|
||||||
|
|
||||||
if pysaj_sensor.name in ("current_power", "total_yield", "temperature"):
|
if pysaj_sensor.name in ("current_power", "temperature"):
|
||||||
self._attr_state_class = STATE_CLASS_MEASUREMENT
|
self._attr_state_class = STATE_CLASS_MEASUREMENT
|
||||||
if pysaj_sensor.name == "total_yield":
|
if pysaj_sensor.name == "total_yield":
|
||||||
self._attr_last_reset = dt_util.utc_from_timestamp(0)
|
self._attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue