Automatically turn off thermostat if door is open for so long

I have door sensors on all my doors right now, and I’m trying to figure out how to turn off my thermostat if the door is left open for more than 30 seconds or 1 minute.

I can create an automation for setting a timer when one of the doors is opened, but I can’t figure out how to get the current state of the themostat (heat/cool) and restore that state once all the doors have been closed. Does that make any sense?

Store the value in in input text or input select.

condition:
  - condition: state
    entity_id: climate.XXXX
    state:
      - heat
      - cool
action:
  - service: input_select.select_option
    target:
      entity_id: input_select.hvac_mode
    data:
      option: "{{ states('climate.XXXX') }}"
  - delay: 2
  - service: climate.set_hvac_mode
    data:
      hvac_mode: 'off'
    target:
      entity_id: climate.XXXX    

Then use a similar set up to set it back:

action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: "{{ states('input_select.hvac_mode') }}"
    target:
      entity_id: climate.XXXX
2 Likes

I have a ‘Door Open’ input boolean. When one of my doors is open for > 30 seconds the ‘Door Open’ is turned on, triggering an automation to turn my AC off. When all of the doors are shut for > 1 minute the ‘Door Open’ is turned off, triggering another automation to turn the AC back on. My thermostat has an ‘auto’ setting, which is essentially ‘heat/cool’ that I use exclusively. You could use separate automations for heat and cool if you don’t have an ‘auto’ setting.

This worked great, thanks!