Block automations.yaml based on true/false condition

Hi

I would like to block all automations in automations.yaml file based on true/false condition.

Following code should block any actions, but it doesn’t.
condition:

  • condition: template
    value_template: ‘{{ not is_state(“sensor.price_below_threshold”, “true”) }}’

I checked that the condition returns correct state, but the automation still works after “true” state. Any further ideas why this is not the case?

alias: IVT control
description: Styra värmepumpen via Nordpool spotpris med relä
trigger:
  - platform: state
    entity_id:
      - sensor.nordpool_kwh_se3_sek_3_095_025
condition:
  - condition: template
    value_template: '{{ not is_state("sensor.price_below_threshold", "true") }}'

action:
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: sensor.electricity_price_4_levels_24h
            above: 3
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.hue_smart_plug_1_3
            data: {}
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.shelly1_244cab43e0e5
          - service: notify.notify
            data:
              message: "Nivå 4: dyrt"
              title: Expensive
      - conditions:
          - condition: numeric_state
            entity_id: sensor.electricity_price_4_levels_24h
            above: 2
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.hue_smart_plug_1_3
            data: {}
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.shelly1_244cab43e0e5
          - service: notify.notify
            data:
              message: "Nivå 3: normal"
              title: Normal
      - conditions:
          - condition: numeric_state
            entity_id: sensor.electricity_price_4_levels_24h
            above: 1
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.hue_smart_plug_1_3
            data: {}
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.shelly1_244cab43e0e5
          - service: notify.notify
            data:
              message: "Nivå 2: billigt"
              title: Cheap
      - conditions:
          - condition: numeric_state
            entity_id: sensor.electricity_price_4_levels_24h
            above: -1
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.hue_smart_plug_1_3
            data: {}
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.shelly1_244cab43e0e5
          - service: notify.notify
            data:
              message: "Nivå 0: Gratis"
              title: Burn it
    default:
      - service: light.turn_on
        target:
          entity_id: light.hue_white_lamp_1
        data: {}
      - service: switch.turn_off
        data: {}
        target:
          entity_id: switch.shelly1_244cab43e0e5
      - service: notify.notify
        data:
          message: "Nivå 1: väldigt billigt"
          title: Bäst
mode: restart

Hello Pluck8953,

If you look at that sensor in developer / states, what is it.
I ask because you are looking for it to say true, which is possible but since that’s a sensor and not a binary_sensor, it will be true in a text form not in a logical form.

Getting confused there could cause an issue, just make sure it’s looking correct.

Yes, I confirmed both on the dashboard and via Developer/states that it changes based on number input from helper.

It must be something simple mistake i made, eventhough I verified by YAML verifier, Gemini and ChatGPT.


“True” is not the same as “true”. States are always strings and capitalization, spaces, and punctuation all need to match.

condition:
  - condition: template
    value_template: '{{ not is_state("sensor.price_below_threshold", "True") }}'

Good catch :slight_smile: I’ll correct it.
One quick one ontop, i began to use automations in the UI and had to remove the IVT auto in automation.yaml, since the UI generated error 500.
However, i tried to add the IVT.yaml to configuration.yaml but configuration file failed

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
**xxsomethingxx: !include IVT.yaml**
script: !include scripts.yaml
scene: !include scenes.yaml