(SOLVED) Catch subtle falling temperature

EDIT: Would this setup work? If it drops -0.3 over 2h period (7200s) -0.3/7200 = -0.00004 or am I thinking wrong here?

- platform: trend
  sensors:
    indoor_temperature_falling:
      entity_id: sensor.indoor_temperature_average
      sample_duration: 7200
      max_samples: 120
      min_gradient: -0.00004
      device_class: cold

TL;DR How to catch subtle falling temperatures that happens over a some hours? Help setting up trend sensor as I can’t really get the hang on it.

Hey, so our landlord is pretty bad when it comes to heating. They use some old hay burner to keep our houses warm but it comes with a catch… it needs to be refilled and so sometimes we are left out with falling temperatures and need to notify them to get heating up. With a newborn this situation is not ideal and therefore we do keep asking for a better solution.

But in the meantime, how can I catch the falling temperature? I’ve tried with the trend sensor and derivative binary sensor but I don’t know how to set it up correctly to catch the subtle but falling temperatures that occur when the heating starts to fail.

Here it how it looked last night (not sure what to do with the spikes, this is an min_max sensor with all my indoor temp sensors.):

As you can see it happens over a long period of time and is falling slowly. And you can also tell when it starts to work again. The outside temperature at the time was between +4C and -1C so it was not that cold outside. A windy or cooler day the fall is more rapid.

Set up your trend sensor. Wait until the temperature starts falling. Then look at the trend sensor attributes in Developer Tools / States or by looking in the more info pop-up when you click on the trend entity in a Lovelace card.

Look at the current gradient attribute. Say it is -63e-6 °C/s (equal to -2.4°C / 10 hours). You need to set min_gradient to slightly less than this for the binary sensor to turn on when the temperature starts falling faster than this rate. Say -65e-6.

Set the sample duration to 3600s (1 hour) to reduce the chance of the small drops in temperature from triggering the sensor.

Set the max_samples to 120. This allows you to collect from a sensor that updates every 30 seconds for 1 hour without losing any samples.

If you measure the temperature directly at the intake pipe, then you should see steeper curves and sooner, which combined with tom_I’s solution should give a earlier alarm.

Say it is -63e-6 °C/s (equal to -2.4°C / 10 hours).

Hmm I don’t follow here sorry. What is -63e?

It seems that the changes are so small that of -0,2/h and that can occur normally ass well so If I just look at a sample duration of an hour would it not trigger the false positives?

Something like this?

- platform: trend
  sensors:
    indoor_temperature_falling:
      entity_id: sensor.indoor_temperature_average
      sample_duration: 3600
      max_samples: 120
      min_gradient: -0.000055
      device_class: cold

-63e-6 is scientific notation for -0.000063

-63 x 10 ^-6

I’m lazy. I don;t like typing so many zeros.

If it is an issue increase the time, and samples. The problem is that longer you use the longer it takes for your binary sensor to turn on.

1 Like

Alright. I’ve been using my math far to rarely I see, thanks for the clarification.

In your example with -2,4°C over 10h, would I not be needing to set the sample duration the match 10h as well then? Or is the sample duration just looking if in that hour of samples, if in that rate it will hit -2,4°C over 10h?

EDIT: So in my case, it seems like I have a drop around -1°C in 10h so I could use a min_gradient: -0.000027? You said to set it a little lower, so around -0.00003?

No you only need to match the gradient of the fall, you can match it over a shorter time.

Start with that value (and the other two settings).

But as I said, wait for the temperature to start dropping and look at the gradient attribute to get the exact value.

1 Like

Thanks a lot!

How can I utilize a trend sensor for monitoring water levels, such that if the flow rate is too high, it may indicate a leak or an open tap?

Look at your flow history. What is your maximum flow rate?

How long does it usually last?

Trigger on that rate being exceeded for longer than that length of time (numeric state trigger, for…)

This will not trigger on a slow leak.