Message malformed: Expected a dictionary @ data['actions'][0]['choose'][0]['conditions'][0]

I get the error “Message malformed: Expected a dictionary @ data[‘actions’][0][‘choose’][0][‘conditions’][0]” when trying to save an automation YAML. I don’t know how to solve this; I tried looking for bad formatting or unnecessary spacing but can’t figure it out. Can anyone point me in the right direction? Thanks for your help.

alias: Smartplugs (boiler)
description: "Activeren van de smartplugs in functie van de zonne-energie"
triggers:
  - id: '0W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 
    below: 440
  - id: '450W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 450
    below: 900
  - id: '900W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 900
    below: 1200
  - id: '1200W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 1200
    below: 1650
  - id: '1650W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 1650
    below: 2100
  - id: '2100W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 2100
    below: 2950
  - id: '2950W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 2950
    below: 3400
  - id: '3400W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 3400
    below: 3850
  - id: '3850W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 3850
    below: 5200
  - id: '5200W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 5200
    below: 
conditions:
  - condition: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 0
  - condition: numeric_state
    entity_id: input_number.boiler
    below: 95
actions:
  - choose:
      - conditions: "{{ trigger.id = '0W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
              - switch.smartplug_89baf0_relay
              - switch.smartplug_cbcd0b_relay
              - switch.smartplug_ec6a00_relay
              - switch.smartplug_f28324_o1_relay
              - switch.smartplug_f283ff_o1_relay
      - conditions: "{{ trigger.id = '450W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_89baf0_relay
                - switch.smartplug_cbcd0b_relay
                - switch.smartplug_f28324_o1_relay
                - switch.smartplug_f283ff_o1_relay
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay
      - conditions: "{{ trigger.id = '900W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay
                - switch.smartplug_f28324_o1_relay
                - switch.smartplug_f283ff_o1_relay
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay
                - switch.smartplug_89baf0_relay
      - conditions: "{{ trigger.id = '1200W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay #450W hoek
                - switch.smartplug_89baf0_relay #450W thermostaat
                - switch.smartplug_f28324_o1_relay #1350W schuifraam
                - switch.smartplug_f283ff_o1_relay #1750W deur
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay #1200W boiler
      - conditions: "{{ trigger.id = '1650W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay #450W hoek
                - switch.smartplug_f28324_o1_relay #1350W schuifraam
                - switch.smartplug_f283ff_o1_relay #1750W deur
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay #1200W boiler
                - switch.smartplug_89baf0_relay #450W thermostaat
      - conditions: "{{ trigger.id = '2100W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_f28324_o1_relay #1350W schuifraam
                - switch.smartplug_f283ff_o1_relay #1750W deur
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay #1200W boiler
                - switch.smartplug_89baf0_relay #450W thermostaat
                - switch.smartplug_ec6a00_relay #450W hoek
      - conditions: "{{ trigger.id = '2950W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay #450W hoek
                - switch.smartplug_f28324_o1_relay #1350W schuifraam
                - switch.smartplug_89baf0_relay #450W thermostaat
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay #1200W boiler
                - switch.smartplug_f283ff_o1_relay #1750W deur
      - conditions: "{{ trigger.id = '3400W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay #450W hoek
                - switch.smartplug_f28324_o1_relay #1350W schuifraam
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay #1200W boiler
                - switch.smartplug_f283ff_o1_relay #1750W deur
                - switch.smartplug_89baf0_relay #450W thermostaat
      - conditions: "{{ trigger.id = '3850W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_f28324_o1_relay #1350W schuifraam
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay #1200W boiler
                - switch.smartplug_f283ff_o1_relay #1750W deur
                - switch.smartplug_89baf0_relay #450W thermostaat
                - switch.smartplug_ec6a00_relay #450W hoek
      - conditions: "{{ trigger.id = '5200W' }}"
        sequence:
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay #1200W boiler
                - switch.smartplug_f283ff_o1_relay #1750W deur
                - switch.smartplug_89baf0_relay #450W thermostaat
                - switch.smartplug_ec6a00_relay #450W hoek
                - switch.smartplug_f28324_o1_relay #1350W schuifraam
    default: []
mode: single

The problem lies in all the conditions of the choose blocks. You are using = (assignment) instead of == (comparison).

Wrong:

conditions: "{{ trigger.id = '0W' }}"

Correct:

conditions: "{{ trigger.id == '0W' }}"

You need to adjust this in all 10 places.

And then the first and last triggers have an empty above: or below: value. You just have to discard them if there is no value:

Wrong:

  - id: '0W'
    above:        # ←empty, remove
    below: 440

  - id: '5200W'
    above: 5200
    below:        # ← empty, remove

Correct:

  - id: '0W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    below: 440

  - id: '5200W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 5200

HA expects a number for above and below, so an empty value results in an error.

Here is a working automation

alias: Smartplugs (boiler)
description: "Activeren van de smartplugs in functie van de zonne-energie"
triggers:
  - id: '0W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    below: 440
  - id: '450W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 450
    below: 900
  - id: '900W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 900
    below: 1200
  - id: '1200W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 1200
    below: 1650
  - id: '1650W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 1650
    below: 2100
  - id: '2100W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 2100
    below: 2950
  - id: '2950W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 2950
    below: 3400
  - id: '3400W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 3400
    below: 3850
  - id: '3850W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 3850
    below: 5200
  - id: '5200W'
    trigger: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 5200
conditions:
  - condition: numeric_state
    entity_id: sensor.smartmeter_power_produced
    above: 0
  - condition: numeric_state
    entity_id: input_number.boiler
    below: 95
actions:
  - choose:
      - conditions: "{{ trigger.id == '0W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_89baf0_relay
                - switch.smartplug_cbcd0b_relay
                - switch.smartplug_ec6a00_relay
                - switch.smartplug_f28324_o1_relay
                - switch.smartplug_f283ff_o1_relay
      - conditions: "{{ trigger.id == '450W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_89baf0_relay
                - switch.smartplug_cbcd0b_relay
                - switch.smartplug_f28324_o1_relay
                - switch.smartplug_f283ff_o1_relay
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay
      - conditions: "{{ trigger.id == '900W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay
                - switch.smartplug_f28324_o1_relay
                - switch.smartplug_f283ff_o1_relay
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay
                - switch.smartplug_89baf0_relay
      - conditions: "{{ trigger.id == '1200W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay
                - switch.smartplug_89baf0_relay
                - switch.smartplug_f28324_o1_relay
                - switch.smartplug_f283ff_o1_relay
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay
      - conditions: "{{ trigger.id == '1650W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay
                - switch.smartplug_f28324_o1_relay
                - switch.smartplug_f283ff_o1_relay
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay
                - switch.smartplug_89baf0_relay
      - conditions: "{{ trigger.id == '2100W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_f28324_o1_relay
                - switch.smartplug_f283ff_o1_relay
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay
                - switch.smartplug_89baf0_relay
                - switch.smartplug_ec6a00_relay
      - conditions: "{{ trigger.id == '2950W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay
                - switch.smartplug_f28324_o1_relay
                - switch.smartplug_89baf0_relay
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay
                - switch.smartplug_f283ff_o1_relay
      - conditions: "{{ trigger.id == '3400W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_ec6a00_relay
                - switch.smartplug_f28324_o1_relay
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay
                - switch.smartplug_f283ff_o1_relay
                - switch.smartplug_89baf0_relay
      - conditions: "{{ trigger.id == '3850W' }}"
        sequence:
          - action: switch.turn_off
            target:
              entity_id:
                - switch.smartplug_f28324_o1_relay
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay
                - switch.smartplug_f283ff_o1_relay
                - switch.smartplug_89baf0_relay
                - switch.smartplug_ec6a00_relay
      - conditions: "{{ trigger.id == '5200W' }}"
        sequence:
          - action: switch.turn_on
            target:
              entity_id:
                - switch.smartplug_cbcd0b_relay
                - switch.smartplug_f283ff_o1_relay
                - switch.smartplug_89baf0_relay
                - switch.smartplug_ec6a00_relay
                - switch.smartplug_f28324_o1_relay
    default: []
mode: single
3 Likes

Thank you for helping me, I got it resolved thanks to you.

1 Like