Skip to content

Support for counting average of long-term statistics sensor #223

@kheikola

Description

@kheikola

Checklist

  • I have filled out the template to the best of my ability.
  • This only contains 1 feature request (if you have multiple feature requests, open one feature request for each feature request).
  • This issue is not a duplicate feature request of previous feature requests.

Is your feature request related to a problem? Please describe.

I'm trying to calculate monthly average of electricity spot price, which changes every hour. With following arguments it should work nicely:
start: "{{ now().replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
However, my recorder purge_keep_days is the default 10 days, and increasing that to 31 days would explode the database size. So it means the sensor which I'm calculating monthly average, only contains last 10 days worth of data.
As my goal is to calculate average for full month, result starts to fail after day 11.

Describe the solution you'd like

As the sensor from which I'm counting the average has state_class: measurement, it has the long-term statistics. So I can see the sensor history for the full month. However it seems that average does not count for long-term history measurements.
So can it be enhanced to calculate average also using long-term statistics data?

Describe alternatives you've considered

Alternative obviously is extending recorder purge_keep_days to 31, but despite recorder exclusions and purge automation for largest sensors, it would still increase my recorder db size dramatically.

Additional context

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions