Unhashable type: 'list' on template condition

Tags: #<Tag:0x00007fc415d9d7e0> #<Tag:0x00007fc415d9d6f0>

Hi All,

I am having a few issues using condition templates for an action.

My understanding is a template condition needs to return a boolean, which mine does, however when I use the expression it throws unhashable type: 'list'.

If I use a system_log.write action with the same expression True (or False) is written to the log.

The expression is as follows:

action:
  - condition:
     - condition: template
       value_template: "{{ trigger.payload_json['action'] == 'toggle' }}"
  - service: system_log.write
    data:
      message: "{{ trigger.payload_json['action'] == 'toggle' }}"
  - service: light.toggle
    target: !input target_light

Obviously to get it to write to the log I have to comment out the condition but to my eyes this should work…

Cheers

What is the JSON you’re expecting to parse? Can you log just {{ trigger.payload_json }} and see what you get?

Thanks for your response.

The output to {{ trigger.payload_json }} is {'action': 'toggle', 'battery': 87, 'linkquality': 27, 'update': {'state': 'idle'}, 'update_available': False} and {{ trigger.payload_json['action'] }} is 'toggle'