guerrerotook / securitas-direct-new-api

This repository contains the new securitas direct API that can be integrated in Home Assistant
Apache License 2.0
73 stars 30 forks source link

Enhancement request: Long-Term Statistics support for Sentinel sensors #198

Closed pauljwhelan closed 6 months ago

pauljwhelan commented 6 months ago

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

guerrerotook commented 6 months ago

I added these two lines of code and they will be included in the next release! Thanks for the tip.

pauljwhelan commented 6 months ago

Thanks for that. And thanks for all the work on this integration.

Cheers Paul