DSMR integration should provide max, min and average power values

Issue
The integration DSMR can be set to report data every X seconds (“Time between updates”), but this is performed by dropping telegrams, and all readings not reported to the UI are completely lost, they are not used for averaging/integrating.

Power flows are skewed when telegrams are dropped. Automations requiring their knowledge are impacted.
Energy consumption is still correct, because it is provided by DSMR separately, but it gets updated every 5 minutes or so, while power consumption might be needed with much higher granularity.

Practical case
Soon in The Netherlands power produced and sold to the network will involve, in some hours, actual costs for the user. This means quite a number of people will need to monitor power (not energy!) consumption continuously to decide whether the solar panels should be turned on or off, or, where possible, their power output limited to actual needs.
Doing this involves (depending on the algorithm chosen) monitoring peak and average power flows continuously.

If DSMR blindly drops telegrams, that won’t be possible (accurately) anymore because the algorithm will be blind to anything happening between the previous update and the current update, only instantaneous values are passed by the integration to HA. And instantaneous values can be affected by devices working in PWM, like stoves, microwaves ovens, …

The documentation clearly states that “Reducing the default time between updates will increase the amount of events generated and can potentially flood the system with events” so I cannot (I should not?) set up DSMR to provide data every second.

Solution

For each power quantity reported (production/consumption, low/normal tariff) add three extra entities: max, min and average power since the last reporting interval set up in the configuration. So the integration would catch every telegram from the DSMR (in my case, about one a second!), keeping track of max, min, average, then when it’s time to report to HA (30 seconds to keep HA responsive), provide the last telegram (as it does now), plus the statistical ones about the telegrams which have been received in the time between.

This will allow to keep a low number of events in HA, while maintaining a perfect knowledge of the energy flows happening between them.