mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add state class support to SAJ Solar Inverter (#52261)
This commit is contained in:
parent
a93487f389
commit
94a0259743
@ -1,11 +1,17 @@
|
||||
"""SAJ solar inverter interface."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date
|
||||
import logging
|
||||
|
||||
import pysaj
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||
from homeassistant.components.sensor import (
|
||||
PLATFORM_SCHEMA,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
SensorEntity,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_NAME,
|
||||
@ -27,6 +33,7 @@ from homeassistant.core import CALLBACK_TYPE, callback
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.event import async_call_later
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -169,6 +176,11 @@ class SAJsensor(SensorEntity):
|
||||
self._serialnumber = serialnumber
|
||||
self._state = self._sensor.value
|
||||
|
||||
if pysaj_sensor.name in ("current_power", "total_yield", "temperature"):
|
||||
self._attr_state_class = STATE_CLASS_MEASUREMENT
|
||||
if pysaj_sensor.name == "total_yield":
|
||||
self._attr_last_reset = dt_util.utc_from_timestamp(0)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user