I wanted to graph the Temperature and Humidity statistics from Sentinel on a Statistics Graph card but the entities were not available to select. I did a bit of digging in the developer documentation (https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics) and found that sensors require the state_class property to be set as MEASUREMENT.
I managed to make the necessary changes and am now able to graph the measurements.
The changes made to sensor.py are as follows:
Changed line 13: from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
to: from homeassistant.components.sensor import (SensorDeviceClass, SensorEntity, SensorStateClass)
After line 105: self._attr_device_class = SensorDeviceClass.TEMPERATURE
I added: self._attr_state_class = SensorStateClass.MEASUREMENT
After line 144: self._attr_device_class = SensorDeviceClass.HUMIDITY
I added: self._attr_state_class = SensorStateClass.MEASUREMENT
I have attached a copy of the sensor.py with these changes included.
sensor.zip
I am not a developer so someone who knows a lot better than I do will need to verify what I've done but if they are proven to be valid could they be made permanent?
I wanted to graph the Temperature and Humidity statistics from Sentinel on a Statistics Graph card but the entities were not available to select. I did a bit of digging in the developer documentation (https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics) and found that sensors require the state_class property to be set as MEASUREMENT. I managed to make the necessary changes and am now able to graph the measurements.
The changes made to sensor.py are as follows:
Changed line 13: from homeassistant.components.sensor import SensorDeviceClass, SensorEntity to: from homeassistant.components.sensor import (SensorDeviceClass, SensorEntity, SensorStateClass)
After line 105: self._attr_device_class = SensorDeviceClass.TEMPERATURE I added: self._attr_state_class = SensorStateClass.MEASUREMENT
After line 144: self._attr_device_class = SensorDeviceClass.HUMIDITY I added: self._attr_state_class = SensorStateClass.MEASUREMENT
I have attached a copy of the sensor.py with these changes included. sensor.zip
I am not a developer so someone who knows a lot better than I do will need to verify what I've done but if they are proven to be valid could they be made permanent?
Many thanks