Do I need to create intermediate helpers?

Let’s say I want to get an alert when the estimated usage of my /data filesystem reaches 100% usage, a month in advance (so that I can plan for expansion, cleanup , etc.)

I can create

  • a change_second statistics helper on the value of the usage, which gives me a value in %/s.
  • I also have the current usage so I can calculate the time in seconds until 100% as (100-current_value)/change_second and assign it to a template sensor.

This creates a helper that is not useful, except, well, as a helper – but one I will never need to see.

Do I need to create such “intermediate” values (= helpers), or is this something I could compute directly in a template?

You are literally the only person who can answer this.

Basically you’re asking ‘do I show my work.’

Yes you can calculate all of that inside one process and show the result OR not totally up to you. If you need the value should be your guide. One way is easier one way is computationally more expensive technically…but either way it should provide you the data you need. I just used an intermediate calculation to provide data to another calculation fot how long my a
LLM prompt is it was helpful to me to two stage calc and expose a number halfway along…

Also, if you’re counting time to disk full in seconds. You probably need a new disk.

I know that I need a time: the time in seconds when the usage gets to 100%. if I can calculate the stats in the template (specifically the gradient), how would I do that?

Why? The usage is given in percentage and the change in %/s, so I do not have a choice. This is just a matter of units anyway

‘how would i do that?’

That totally depends on your data etc.

Best advice just start writing a process that yields your result in the developer tools template editor. What do you have now? If it works there it’s likely valid for the state template of a sensor. Try to get your value. Then if you need help bring the attempt back for help

I don’t know what data you have available what form it takes so most of the answer rn is an educated guess.we need a lot more to get detailed and all that is best shown in what you’ve done already. .

And yes I know what’s provided my point was if you’re resolving to seconds you already need the disk ordered. If it’s 9*10^32 seconds you have some time but you’re representing the time in the wrong scale. :wink:

I have a sensor that provides a float with the usage of a filesystem. It has a history. I need to calculate the fitted slope (or change of % in time).

There is a Statistics module for that, which allows me to compute %/s as a helper.

I do not want to use a helper because it is used only as an intermediate value. I only need its value when computing the formula I gave above in a template.

Is this doable, or do I need the helper for that?

If yes, can you please give me an example of a template that would use the stats module inline instead of a helper?

I don’t understand this. HA (or actually System Monitor) provides me a percentage of the usage, and Statistics provides me a “unit-per-second”. I have no choice.

This has nothing to do with resolving to seconds and ordering disks. Today I have a change of 5e-7 %/s, which gives me about 30 months of slack.

These are just units.

Have you considered making an automation which periodically queries the statistics history over a known time range. You can process this data to determine the rate of change. You can look at the amount of free space or in your case free percentage and calculate how long it will take for that to be consumed.

You can then update a helper such as an input number with that value.

The more advanced option that you have is to use a template number and use the action inside the template number triggered say every 5 minutes to recalculate the value of the number.

I expect you may have to look up in the documentation, or ask and llm how to go about working with history, statistics and working with a template number.