Hi HA Community.
I’m attempting to average power generation and consumption for my house (I’ve got a fronuis inverter with a modbus TCP link and I can pull in all the data). The problem is that the averaging functions in statistics only triggers on state change, so for example I’ve found that the average solar generation hangs (e.g. at 89.15W) due to the last state change to 0W when the inverter stopped producing power. It has been mentioned on a few other threads but I have not seen a solution.
I also looked into History Statistics, however that is targeted at measuring the duration of a device being active. Before I dive in and attempt to merge the two components, has anyone created their own component, or resolved the limitation with the statistics component only executing when the sensor changes state?
You could use an automation/python_script to poll the state every second, then do your stats on that
Thanks for the suggestion, the script would have to store/hold past values for the defined period. As the data is already stored in the data base (history), it would be much neater to do a query on the database, rather than create overhead with another script/store values. I’ll try that if I can’t create a component.
I believe you could export your data to influxdb and then use the influxdb sensor component to achieve what you are looking for.
CanonGuy, that looks like a neater way of achieving the functionality. Although it is creating another database. I shall try this if I cannot get the data from history.
You can access be Database directly with python. Been doing that myself https://github.com/robmarkcole/HASS-data-science