If then on a climate entity

I want my AC to come on when the temperature os over 21 degrees.

The trace shows that the value is 25 degrees so i am at a loss as to why the if then statement below always fails.

It says State not value - but that was created by the UI editor so I have to asume it is correct.

Can anyone please assist ?


  • if:
    • condition: state
      state: “>21.00”
      entity_id: climate.master_bedroom_2
      attribute: current_temperature
    • service: climate.turn_on
      entity_id: climate.master_bedroom
      data: {}
    • service: climate.set_fan_mode
      metadata: {}
      fan_mode: HIGH
      entity_id: climate.master_bedroom
      mode: single

First format your code properly, so that we can see if there’s any problem in indent etc…

But, quick look shows that you are not defining hvac mode, you only turn climate on and set fan mode. Set HVAC mode to “cool” also.
Second, i think that state: “>21.00” won’t do. You must use state_above or similar…
EDIT: quick look in my automations: try similar as this as condition:

  - platform: numeric_state
    entity_id: sensor.basement_humidity
    above: '80'

Consider this instead:

But this won’t work:

  - if:
    - condition: state
      state: ">21.00"
      entity_id: climate.master_bedroom_2
      attribute: current_temperature

Where did you get the idea that “>21.00” would do what you wanted?

Please publish the correctly-formatted YAML for the entire automation or script, whatever this is.

Huh? Are we all making stuff up now? Here’s the numeric state condition, which is closest to what is needed:

Sorry,i was answering (too) quickly… i posted an example above.

Thank you for your replies.

If i cut and then paste the YAML then that is what shows so I have no way i know of of pasting the formatted yaml.

An image is attached.

Why would i think it would work ? Well temperature is a number and i have used many similar things in automations.

I dont want it to act as a thermostat. This runs at sunset and if the bedroom is warm i want it to turn on the AC. There is another automation that runs in the morning to turn off all bedrooms .

Hence I would like help with the IF statement that is true if the temp is over 21.

Screenshot 2024-05-15 at 12.43.07

The trace shows the state as 25.6 which is correct - and is also over 21 - hence my expectation that it would work

Screenshot 2024-05-15 at 12.38.47

That is literally impossible. state: does not accept any kind of conditionals. In fact, all the code does in HA is compare the value in state: to the state value of the entity. It does no conditional checking at all. Ever.

What you want to use is a numeric_state trigger.

You have never successfully used “>x” in a state automation.

Your code is looking for the attribute to be the string ">21.00" which will never happen.

Here’s what you need:

- if:
  - condition: numeric_state
    entity_id: climate.master_bedroom_2
    attribute: current_temperature
    above: 21

That worked - thank you

Show Your Whole Automation, so you dont confuse people :wink: