Statistics helper min value

Hi,

I’m trying to make a statistics helper that gathers sensor measurements over 20 seconds continuously and provides the minimum measured value in this timeframe. So every 20 seconds you get a new value based on the minimum value found in all measurements during this time. This keeps on repeating every 20 seconds. The goal is to avoid having too much temporary spikes triggering / untriggering automations.

Unfortunately I don’t seem to get this working, sometimes the helper is updated within a few seconds upon change in the source sensor value.

The entered settings in the min. value statistics helper:

  • Statistics → min value
  • max age 20 seconds
  • sample size 100
  • percentile 1
  • precision 2

Can anyone point me in the right direction?

Thanks in advance!

PS: below some additional info if it should be usefull:


The min value helper is based on the template helper above.

This is the configuration of the template helper:

These are the settings of the min value statistics helper:


Do I understand it correctly that your problem is that you only want to know the minimum value at an interval of 20 seconds?

The statistics integration can give the minimum value over the last 20 seconds (the max_age), but is updated whenever the monitored sensor gets an updated lower value.

Your template sensor calculates a value based on several other sensors.
This means that the template sensor gets a new value at every state change of any of these other sensors.
So the statistics sensor finds a new minimum value whenever one of the values is indeed lower than it was before in the last 20 seconds.
This can happen much more frequently then every 20 seconds, depending on how often the underlying sensors are updated.

A solution could be to make an automation that reads the min value from the statistics sensor at a 20 seconds interval, and writes this value to for instance an input number that you then can use is input for the other automations.
An alternative can be a template sensor with a time pattern trigger.

Why are you specifying a percentile value for the statistics sensor?
Since you are using the state characteristic value_min this is not relevant. See: percentile.