YAML works as trigger but not as condition

The point is, if you make one big trigger template, it only fires if the template is true. So it is both the trigger and the conditions in one. It will make one huge trigger template, but no duplication required. HA checks which entities affect the template trigger.

Doesn’t work.

Message malformed: Expected a dictionary @ data['condition'][4]

Have you checked the template in developer? I couldn’t myself as I do not have your sensors. Also check the indenting. Is this indeed condition nr 4? And is there something around it that could be wrong?

Developer says something like this:

UndefinedError: 'sensor' is undefined

Also in you YAML there’s “(” before first states but not before second states. I changed to this but still doesn’t work:

- condition: template
  value_template: >-
    {{ states(sensor.outdoor_temperature) | float(0) + 3 <
    states(sensor.oczyszczacz_powietrza_biuro_temperatura) | float(0) }}

The braces where there for the + 3. Not sure they are needed. But I forgot the quotes around the sensor names. I’ll fix it above.

OK - now it became real wierd. Template in developer says it’s OK! Even shown TRUE or FALSE depending if condition is met. However when putted into automation it says:

Expected a dictionary

Maybe post the whole automation, I expect it is something in the vincinity.

Sure thing:

alias: >-
  Biuro vent [ON] <- Biuro temp > Outside temp OR Biuro temp [>BIURO SET TEMP]
  OR Biuro temp [CHANGED] OR Biuro door [CLOSED] OR Biuro window [OPEN] WHILE
  [ALL IN ABOVE] AND Heat pump {SUMMER MODE}
description: ''
trigger:
  - type: opened
    platform: device
    device_id: 19423dcee9267d9acf28689aea88d335
    entity_id: binary_sensor.office_window_ias_zone
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 0
  - type: not_opened
    platform: device
    device_id: c2a6fbed0f1a870a4f152f3cf58f450c
    entity_id: binary_sensor.office_door_ias_zone
    domain: binary_sensor
  - platform: numeric_state
    entity_id: sensor.outdoor_temperature
    value_template: '{{ state.state|float(0) + 3 }}'
    below: sensor.oczyszczacz_powietrza_biuro_temperature
    for:
      hours: 0
      minutes: 1
      seconds: 0
  - platform: numeric_state
    entity_id: sensor.oczyszczacz_powietrza_biuro_temperature
    above: input_number.office_room_temp_during_summer
  - platform: numeric_state
    entity_id: input_number.office_room_temp_during_summer
    below: sensor.oczyszczacz_powietrza_biuro_temperature
condition:
  - type: is_open
    condition: device
    device_id: 19423dcee9267d9acf28689aea88d335
    entity_id: binary_sensor.office_window_ias_zone
    domain: binary_sensor
  - type: is_not_open
    condition: device
    device_id: c2a6fbed0f1a870a4f152f3cf58f450c
    entity_id: binary_sensor.office_door_ias_zone
    domain: binary_sensor
  - condition: numeric_state
    entity_id: sensor.oczyszczacz_powietrza_biuro_temperature
    above: input_number.office_room_temp_during_summer
  - condition: state
    entity_id: sensor.hc1_summer_winter_switchmode
    state: 'off'
  - condition: template
    value_template: >-
      {{ (states('sensor.outdoor_temperature') | float(0) + 3) <
      (states('sensor.oczyszczacz_powietrza_biuro_temperatura') | float(0)) }}
action:
  - type: turn_on
    device_id: beeb9968f1d162081bb300b40bdccd32
    entity_id: switch.tasmota_office_stereo
    domain: switch
mode: single

Missed an ‘e’ on temperature. just fyi. But yes the full automation would be helpful.

I know you missed it. I fixed it. Anyway don’t be confused by tasmota_office_stereo. It’s actually a vent just this switch was used for something else before.

I simply forgot to change entities names and now I’m too lazy to do it :wink:

is it temperatura or temperature? I don’t get an errors with your automation saving.

Mayby try to copy the entire script in another editor, abort the editor, open it again and paste the code again. I’ve seen instances that the editor got,stuck in a broken editing session. or arent’t you editing in the GUI?

I do edit in GUI (for most part). I just switched to YAML to post automation here. Anyway I will try your suggestion.

I still got these error after pasting whole script into new automation. Strange thing is however that it ALLOWS me to save this automation without any error. It throwns error only when I click test here:

image

Ahhhh! That is a known bug in the condition test functionality. That is broken, the condition is fine.

Oh really… so I took around 30 minutes of your time to fix something that isn’t broken?

HAHAHAHA… sorry mate :slight_smile: Thank you very much for your help :slight_smile:

1 Like

No worries, glad to help. :smile:

You’re not the only one:

Definatelly someone has to fix this :slight_smile: Or at least remove this test button.