Automation triggered by sensor update, action depending on above/below/in a specific range for 10min

I’d like to create an automation triggered by changes of a template sensor. The action should depend on the value of this template sensor:

  • if the value has been below A for at least 10 minutes, call service X
  • if the value has been between A and B for at least 10 minutes, call service Y
  • if the value has been above B for at least 10 minutes, call service Z

I’ve seen the documentation for Scripts: Choose a Group of Actions but I’m unsure how to add the 10 minutes delay to the conditions and to ensure that it’ll never end up hanging in a limbo state.

As an explanation: I’m trying to optimise my heating based on the average differences between target room temperatures and current room temperatures. So this average value changes very frequently, usually only in tiny steps but it can fluctuation and I don’t want to deal with fluctuations around one of the “border” values by using the above 10 minute delay.

Thanks!

A threshold helper may be helpful. You can define a “hysteresis” - a zone on either side of the threshold where the sensor does not change. It’s intended to smooth out small fluctuations like this.

True, I didn’t think of the hysteresis feature. Unfortunately threshold sensors are binary, so if I want three states (above range, in range, below range), I’d need two threshold sensors and use both in the automation, which I find confusing.

Tell me about it! :roll_eyes: