I am making a DIY rain meter using a tipping bucket sensor. The sensor is connected to an ESP8266, and Home Assistant will get the results through MQTT. I could think of two options for the MQTT input:
-
Within the ESP, I collect the amount rain measured, then periodically publish the result and reset the counter. The problem with this approach is that Home Assistant registers the state in the history only when it changes. So it works for displaying the amount of rain in some period, but I cannot ask questions, such as “how many rain fell yesterday”, because if the amount of rain is the same in two consecutive time periods, then the second one is not registered.
-
When the circuit closes, I publish the amount of rain one impulse represents, then publish a 0 when the circuit opens again. This is useful for example when I publish the data to InfluxDB, so I can make aggregate queries. However, in Home Assistant, I will always get 0 as the result, and I cannot have any current aggregate results.
My question is if there is some way to aggregate data in Home Assistant? For example, one that adds all the samples for a sensor in a certain time period? I found that in the latest version, there is a new sensor called filter. This sounds promising, except that it does not support summing. Is there any other way to achive this? What are the usual practices in Home Assistant for such measurements?