Troon, is the _average suffix in the sensor name some jinja magic in combination with the time pattern sensor that will return the average of all values within this period? Because until now I thought the trigger based template sensor will only return the last value every X minutes.
Or are you suggesting creating two sensors, first calculate a floating average and then use the last value of this floating average every five minutes with the trigger based sensor?
Troon, thanks for the quick reply, I hoped there was a way to prevent an additional sensor (that’s not used other than for a the final calculation).
I wonder why there isn’t a versatile statistics sensor available (or even as part of HA itself). The best I could find is GitHub - Limych/ha-average: Average Sensor for Home Assistant, but it’s not in active development, does not have a time pattern feature and does not provide other calculations (personally I find current deviation from a long term mean most useful). Besides the fact that you need HACS and there’s no UI for it.
EDIT: HA provides the Statistics - Home Assistant sensor, but when the source does not provide a single value in the time frame (e.g. 5 minutes), it changes to “unavailable” instead of using the last known value. This is an issue for sensors that only broadcast data when the value has changed. Also the HA statistics sensor does not allow merging multiple sensors to one (e.g. the average temperature of temperature in multiple rooms).