DurgNomis-drol / ha_toyota

Toyota Connected Services integration for Home Assistant.
MIT License
148 stars 29 forks source link

Add (better) support for Home Assistant Long-Term Statistics #127

Closed CM000n closed 10 months ago

CM000n commented 1 year ago

Screenshot 2023-02-28 193033 Long-term statistics for sensor values have been available in Home Assistant for some time. These long-term statistics are not affected by database purges, take up little space and are very useful for long-term analyses: https://data.home-assistant.io/docs/statistics/

It would be cool if the sensor values of the ha_toyota custom component were also included in these long-term statistics. As you can see in my screenshot from the "Developer Tools -> Statistics" section, only the current weekly, monthly and yearly statistics for my Corolla are currently included in the long-term statistics. By the way, the "reichweite_corolla" sensor here is a self-made template sensor that determines the current remaining range based on the tank level according to the ha_toyota custom component ;-)

The inclusion of further ha_toyota senor values in these long-term statistics should not be a problem. All that needs to be done is to provide the sensors with a valid device_class, state_class and unit_of_measurement.

An overview of the valid device_class options can be found here: https://developers.home-assistant.io/docs/core/entity/sensor/#available-device-classes An explanation of the state_class can be found here: https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics

I'll see if I can find the time to get back into ha_toyota to create a pull request. In any case, I wanted to record it here in case I don't get around to it. Are there any other opinions or ideas?

CM000n commented 10 months ago

Better logterm statistics support with proper device classes will com with V2: https://github.com/DurgNomis-drol/ha_toyota/pull/166