I’m trying to detect if the shower is running using a trend binary sensor. I have a temperature sensor attached to the hot water pipe going the shower.
My shower detection logic would consist of the initial rise of the temperature and then when it’s above 40°C I mark it as showering.
So I need to detect the first incline until 40°C. But I’m having some trouble understanding how I should configure the trend binary sensor.
Here I have plotted an example of the rising temperature after turning on the shower:
2 degrees over 10 seconds and min_gradient is rate of change over 1 second. So 0.2. But you might want to go lower, like 0.15 which is 1.5 over 10 seconds.
EDIT: Uh, this post showed up as new for me for some reason… disregard.
However it has been working quite well, I do have some false positives. I’m not quite sure why tho. If you look at the image at 9:00, there was a detection, but the temperature graph shows no spikes?
binary_sensor:
#----------------------------------------------------------------
- platform: trend
sensors:
showering_start:
entity_id: sensor.showerpipe_temperature_mqtt
friendly_name: Start douchen
# In our case:
# 2 degrees increase in 10 seconds
# 2°C / 10 seconds = 0.2
# Min gradient set to 0.12 to be sure we can get above
min_gradient: 0.12
if your max samples is set to 2, then it will take 2 samples. If the time change between the 2 samples has a large gradient, it will turn on. In @DavidW’s case, we can’t tell because he did not include the microseconds for his state change when it turned on. The math is simple for 2 points. It’s
Vn - Vn-1 / tn - tn-1
So if your time difference is small but V is large, you get a false trigger. Play around with the setup values until you remove the false triggers.
Just so you know how the math works, it fits a 2d line to your dataset, i.e. the number of saved data points. If the line’s first coefficient is greater than the max gradient, it’s on. So, more data points the better, especially if you’re getting a ton of data.