I can't get the NOT is_state condition to work

ok, found out already, it looks like triggering an automation from the GUI does not consider conditions, so much for debugging this way :wink: guess I am at the bottom of the learning curve.


I am trying to get this piece to work but no matter what I do or change, the condition seems to be ignored and it just sets it home or away. What am I doing wrong here?

  - alias: Thermostaat Niemand Thuis
    trigger:
      platform: state
      entity_id: input_select.home_mode
      to: 'Away'
    condition:  
      condition: template
      value_template: "{{ not is_state('climate.toon_thermostat', 'Holiday') }}"
    action:
      - service: climate.set_operation_mode
        data:
          entity_id:  climate.toon_thermostat
          operation_mode: Away

  - alias: Thermostaat Iemand Thuis
    trigger:
      platform: state
      entity_id: input_select.home_mode
      to: 'Home'
    condition:
      condition: template
      value_template: "{{ not is_state('climate.toon_thermostat','Holiday') and
                          not is_state('climate.toon_thermostat','Sleep')  }}"
    action:
      - service: climate.set_operation_mode
        data:
          entity_id:  climate.toon_thermostat
          operation_mode: Home   

State when testing:
Holiday

attributes:
current_temperature: 19.4
min_temp: 7
max_temp: 35
temperature: 7
operation_mode: Holiday
operation_list: Comfort,Home,Sleep,Away,Holiday
mode: 4
friendly_name: Toon Thermostat
supported_features: 129

I’m not a Jinja2 expert but it’s my impression that not is used with if ( like if not) but I may be mistaken.
EDIT
I just tried this in the template editor:
{{ not false }}
and it correctly produced:
True
So the way you’re using not should work.

Perhaps this alternative would work for you?

"{{ states('climate.toon_thermostat') != 'Holiday' }}"

EDIT
Correction. Changed state to states.

1 Like

I don’t see anything wrong either. Are you sure the state is ‘Holiday’ and not ‘holiday’? Of course, looking at the operation_list attribute, it does look like the modes are capitalized.

Maybe add a step before the call to climate.set_operation_mode that creates a persistent notification where the message is state(‘climate.toon_thermostat’).

A bit late on this one but the first word should be states.

“{{ states(‘climate.toon_thermostat’) != ‘Holiday’ }}”

1 Like

You’re right; there was a typo. I have corrected the post.