Capture climate state

Hello - what’s the best way to capture a climate state? Often in the spring/fall I’ll turn off my HVAC system during the day… I want to setup an automation that turns it back on at bedtime. The only way to do that with my Honeywell T9 is to change the state from OFF to either Heat or Cool… that implies I need to programmatically know if it was in Heating or Cooling mode when I turned it off.

How do I do this? Via a Helper variable or a scene or ???

I would use a helper for that if it were me. I do a similar thing myself.

Hi @Brewder

What is the name of your entity that returns Off, Heat or Cool? What is the name of the helper where you want to save the state?

I haven’t created a helper yet… not sure what “type” it should be… my T9 entity is: climate.t9_thermostat

Probably an text helper, say, input_text.t9_saved_state

Then you could call a service like this:

service: input_text.set_value
data:
  value: "{{ states('climate.t9_thermostat') }}"
target:
  entity_id: input_text.t9_saved_state

I will test all this out in the next few days! Thank you!

OK I’m close… I capture the hvac mode in the helper now when the system is turned ON. That’s working… Now how do I use that captured helper variable in an automation to turn the system back on once the automation detects it’s off? I’m not sure how to code the Call Service Climate: Set HVAC mode in yaml/gui.

    - service: climate.set_hvac_mode
      target:
        entity_id: climate.t9_thermostat
      data:
        hvac_mode: "{{ states('input_text.t9_saved_state') }}"

Hmm… It’s not working… It must be something silly. Here is the automation to turn the system back on. I can confirm that the group variable has “heat” when this triggers:

alias: Thermostat - Turn back ON at 10pm if it was off
description: ""
trigger:
  - platform: time
    at: "22:00:00"
condition:
  - condition: state
    entity_id: climate.t9_thermostat
    state: "off"
action:
  - service: climate.turn_on
    target:
      entity_id: climate.t9_thermostat
    data:
      hvac_modes: "{{ states('input_text.thermostat_state') }}"
mode: single

And below are the entities available for my T9 thermostat:

hvac_modes:
  - "off"
  - heat
  - cool
  - heat_cool
min_temp: 45
max_temp: 95
current_temperature: 71
temperature: null
target_temp_high: null
target_temp_low: null
current_humidity: 42
hvac_action: idle
friendly_name: T9 Thermostat
supported_features: 3

You may have to condition it to make HA happy:

hvac_modes: >-
  {% if states('input_text.thermostat_state') == 'heat' %}
    heat
  {% elif states('input_text.thermostat_state') == 'cool' %}
    cool
  {% endif %}

Just verify what the input value really is. If it still doesn’t work then you can do conditions in a different way but night need a script for it.

Still not turning on. Updated yaml:

alias: Thermostat - Turn back ON at 10pm if it was off
description: ""
trigger:
  - platform: time
    at: "22:00:00"
condition:
  - condition: state
    entity_id: climate.t9_thermostat
    state: "off"
action:
  - service: climate.turn_on
    target:
      entity_id: climate.t9_thermostat
    data:
      hvac_modes: >-
        {% if states('input_text.thermostat_state') == 'heat' %}
          heat
        {% elif states('input_text.thermostat_state') == 'cool' %}
          cool
        {% endif %}   
mode: single

This is not the correct service. Look at my original code on my first response:

    - service: climate.set_hvac_mode
      target:
        entity_id: climate.t9_thermostat
      data:
        hvac_mode: "{{ states('input_text.t9_saved_state') }}"

Unless I’m mistaken, you are trying to revert back to your previous MODE, yes? That’s not turn on/turn off, it’s setting the HVAC mode from “off” to “heat” or “cool”.

1 Like

Wow, I did miss that! I made the update and bingo it works like a charm!! Thank you so very much. And for your keen eye finding my mistake.

1 Like

Thanks CO 4x4 this helped me do the same thing! You’re a hoss.