I’m trying to create a sensor to detect if a window has opened. I’m trying to do this by detecting the rapid fall in temperature according to my thermostat.
I’m going to work on the basis that I need to detect if the temperature falls by at least 1 degree celcius in 10 minutes or less.
I believe that I can use a trend sensor for this. I don’t believe the UI version gives sufficient configuration options.
So far I have the following yaml:
# Sensor to indicate dishwasher is cooling down
- platform: trend
sensors:
dishwasher_cooling:
[code not shown]
# Sensor to indicate that window has opened
window_open:
entity_id: climate.thermostat
unique_id: climate_window_opened
invert: false
friendly_name: Climate Window Opened
min_gradient: -0.00167
min_samples: 4
max_samples: 10
sample_duration: 1800
Can someone let me know if this configuration looks right. At the moment, the sensor just reports ‘unknown’
My advice would be to create a derivative helper sensor instead. It is much easier to see what that is doing by graphing the value. you can directly use the value for automations, or you can use what you learned to properly set up the trend sensor. Or use a threshold sensor on the derivative to reach similar results. Personally I simply go by the derivative alone.
I’ll give this a go. I think this is going to be easier to work with. It also attaches itself to the thermostat device and doesn’t require yaml which keeps things tidy.