Dear community members and developers, please take a look and vote or comment on RFC for Reports.
— RFC for Utility Meter Reports in Home Assistant —
Purpose of this change request - to show bar chart or text values in lovelace panel with sensor values aggregated by period (i.e. hour, day, month, quarter, year) in past.
- To improve performance for long reporting periods - only single value per reporting period should be stored.
- To reduce amount of change in the UI - reuse existing charts and lovelace panels functionality
- Functionality must be part of standard HA installation without any integrations to external systems. By this we assume that user should not do any administrative work except a) Supervisor install component b) update configuration.yaml.
New changes marked in bold or in * * stars * *.
Revision 2.0 - Instead of utility_meeter modifications, lets create
For each sensor calculate and record in to
states values per period.
Proposed configuration of component:
aggregate: - period: daily calculate: - delta - last entity_globs: - sensor.*_total_offpeak - period: hourly calculate: - average - min - max entity_globs: - sensor.*_total
Possible calculation functions:
Source data selection logic:
- minimal purge days = 1, then this constraint does not affect period
- by default purge days = 10, then we can check if
weeklydata exists for the sensor. If not see 3.
- If recorder purge days < sensor aggregation period - perform aggregation of the maximum possible period (i.e. daily or weekly) and record aggregation for required period based on aggregation from smaller period (i.e. weekly aggregated value calculated from 7 daily aggregates).
purge_keep_days value from configuration.
Caused by :
- Utility meter reports (daily/monthly/yearly) - #25 by palivoda
- Support for multiple recorder components
- Storing your very long history - RRD Recorder - a PoC alredy implemented but has external dependency on RRD tool.
Currently last sensor value received with states(‘sensor.foo_daily_total’). To receive sensor value in the past or in future (yes! some integrations may feedin future values) we need something like states_history(‘sensor.foo_daily_total’, relativedelta(months=-1)). The
relativedelta function is very flexible and can work with any utility meter report period.
Function will return first value before the date/time passed with relativedelta. For example: if there is value 5 for 31-Dec-2020 then for 1-Jan-2021 or 20-Jan-2021 function will return 5 and for 20-Dec-2021 function will return value recorded before 31-Dec-2020.
- How to check sensor history value at specific time? - #5 by petro
- Historic value in value template - #5 by tom_l
- Easy way to get historical data for numeric sensor (such as total within range) - #4 by xbmcnut
- Can you Extract Data from the History Component - #2 by ptdalen
To allow textual representation of the report values any HA user can create a custom lovelace panel. Panel will use Jinja2 template and Change2 to retrieve historical values for specified period.
Values are stored as a separate sensor state and could be used in charts out of the box.
No code changes will be required for this functionality.
Could be supported by:
- GitHub - thomasloven/lovelace-template-entity-row: 🔹 Display whatever you want in an entities card row. (@thomasloven )
- GitHub - RomRider/apexcharts-card: 📈 A Lovelace card to display advanced graphs and charts based on ApexChartsJS for Home Assistant
— END OF RFC —
Dear community members, please review and like if you agree with RFC. Please comment if something is missed or you disagree - I’ll update this RFC based on your proposals.