How to store a value every few seconds?

Hey guys,

I’m having trouble understanding thd concept of variables.

I have a value every few seconds in an automation and like to store it. So I created an input_number as storage.

But when I try to store the same value multiple times, since it isn’t changing, the variable gets never updated: the development tools show that the variable has had its last update when it was last changed, but my automation did fire.

When I want to calculate the min/max value and the mean over the last 15 minutes with the statistics module, I end up with no output, when the value haven’t changed in the last 15 minutes.

Is this how it’s supposed to work? :thinking:

If so is there a different way to store values in a database?

How many values would you need to store?

If it’s not too many what I use is a custom component called “hass-variables”:

you can use it to store many data points as the attributes of the variable entity you create.

But if you are going to need more than around 10 or so it could get unwieldy to use those attributes in an average/min/max template.

Yeah not gonna work. I need to get accurate sum of a sensor which has pretty long states sometimes and sometimes change rapidly.

So one value every second for 15 minutes should enough, maybe 20.

But currently HA would only calculate each change point as data point.

I though about adding 0.001 to each value to avoid this behavior, but it’s pretty hacky.

I mean, it’s so common for sensors to just send changes in the IoT world, and HA should be able to assume the same value as long as there’s no update.

But even when I send and update with the same value, HA discards it - which is odd.