Add state_class to OHM sensors (#125567)

* Minimum change required to get OHW into statistics

Not sure if there is any reason not to have this, my only idea would be that there would be that there are A LOT of values, but as far as I can see there are already long term data being stored about them anyway

* Update sensor.py

Guess that was an old way of doing it -_-

* Update sensor.py

remove spaces the break ruff -_-

* Update sensor.py

ruff is rough
This commit is contained in:
silentguy256 2024-09-10 16:10:36 +02:00 committed by GitHub
parent d8bb8f1efb
commit 379a8f2f86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,6 +11,7 @@ import voluptuous as vol
from homeassistant.components.sensor import (
PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA,
SensorEntity,
SensorStateClass,
)
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import HomeAssistant
@ -60,6 +61,8 @@ def setup_platform(
class OpenHardwareMonitorDevice(SensorEntity):
"""Device used to display information from OpenHardwareMonitor."""
_attr_state_class = SensorStateClass.MEASUREMENT
def __init__(self, data, name, path, unit_of_measurement):
"""Initialize an OpenHardwareMonitor sensor."""
self._name = name