Sensor to indicate that a window has opened (turn off heating)

Hi all

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’

Thanks

Why not using a door sensor?

You probably need the attribute of the climate.
I would guess it’s current temperature the attribute is called.

# 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
      attribute: current_temperature     ###
      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
1 Like

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.

Thanks @Hellis81

I always forget that the state of the thermostate is the mode.

Thanks @Edwin_D

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.

1 Like