Nested conditions in script - invalid key: OrderedDict error

I’m building a script that will do some action only if specific conditions are true, but the conditions may vary, so I need to test few of them. for now I’ve got:

sequence:
- condition: or
  conditions:
    - condition: and
      conditions:
        - condition: template
          value_template: {{ states.device_tracker.phone.state != 'home' }}
        - condition: template
          value_template: {{ states.input_boolean.test.state == 'off' }}
    - condition: template
      value_template: {{ states.input_boolean.test.state == 'on' }}
- service: ACTION! (...)

my plan is, that ACTION! is executed only if:

  1. input_boolean.test is switched off and phone is not in home (but can be in other zone, so ‘not_home’ is not an option)
  2. input_boolean.test is switched on and it doesn’t matter if phone is at home or not

unfortunately, my sequence fails with:
2018-02-04 00:00:11 ERROR (SyncWorker_0) [homeassistant.util.yaml] invalid key: “OrderedDict([(“states.device_tracker.phone.state != ‘home’”, None)])”
in “/config/scripts/test_script.yaml”, line 7, column 0
2018-02-04 00:00:11 ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: invalid key: “OrderedDict([(“states.device_tracker.phone.state != ‘home’”, None)])”
in “/config/scripts/test_script.yaml”, line 7, column 0

and TBH I don’t know what does it mean…
yamllint.com passes, so there’s no problem with validation.

Put double quotes around all 3 templates.

3 Likes

now I feel stupid… :wink: thanks!
so obvious, so I didn’t even thought about it…

1 Like