Automations error

Hi guys… I was following a guide on a lock code for my schlage lock and everything was going well except for this part. I can’t figure out what is wrong. I get an error on line 20 col 16. “can not read an implicit mapping pair; a colon is missed at line 20, column 16”

What am I missing? Thanks in advance.

alias: Front Lock - Lock Code
description: ''
trigger:
  - platform: event
    event_type: zwave_js_notification
condition:
  - condition: template
    value_template: '{{ trigger.event.data.device_id == ''1e972ghrdjkfhskjafdffkdsajkfhkasd' }}'
  - condition: template
    value_template: '{{ trigger.event.data.event == 5 }}'
action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.last_front_door_code
      value: '{{trigger.event.data.parameters.userId | int}}'
  - service: input_text.set_value
    data_template:
      entity_id: input_text.front_lock_user
      value: >
'{% if states('input_number.last_front_door_code') | int == 1 %}
  Code1
{% elif states('input_number.last_front_door_code') | int == 2 %}
  Code2
{% elif states('input_number.last_front_door_code') | int == 3 %}
  Code3
{% elif states('input_number.last_front_door_code') | int == 4 %}
  Code4
{% elif states('input_number.last_front_door_code') | int == 5 %}
  Code5
{% elif states('input_number.last_front_door_code') | int == 6 %}
  Code6
{% elif states('input_number.last_front_door_code') | int == 7 %}
  Code7
{% elif states('input_number.last_front_door_code') | int == 8 %}
  Code8
{% elif states('input_number.last_front_door_code') | int == 9 %}
  Code9
{% else %}
  Error
{% endif %}'
mode: single

See how your condition is highlighted in red?

Screenshot 2021-11-05 at 10-01-16 Automations error - Configuration - Home Assistant Community

Everything to the left of colons : should show up as white in the formatted text on the forum (strings show up as red, keys as white). That means you must have missed a quote somewhere above the condition. Look at your event device id template (scroll right):

  - condition: template
    value_template: '{{ trigger.event.data.device_id == ''1e972ghrdjkfhskjafdffkdsajkfhkasd'' }}'
                                                                                            ^
                                                                                            |
                                                                                          here

That was an error when I posted it, but the same error is there even after adding the quote.

you also have an extra quote at the beginning of this line above.

The original code I was using has that extra quote for some reason. When I remove it, then I get this error "missed comma between flow collection entries at line 20, column 2:
{% if states('input_number.last_f … "
^

Post what you have now.

Here it is…

alias: Front Lock - Lock Code
description: ''
trigger:
  - platform: event
    event_type: zwave_js_notification
condition:
  - condition: template
    value_template: '{{ trigger.event.data.device_id == ''445eaa0e224212800af3'' }}'
  - condition: template
    value_template: '{{ trigger.event.data.event == 6 }}'
action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.last_front_door_code
      value: '{{trigger.event.data.parameters.userId | int}}'
  - service: input_text.set_value
    data_template:
      entity_id: input_text.front_lock_user
      value: >
{% if states('input_number.last_front_door_code') | int == 1 %}
  Code1
{% elif states('input_number.last_front_door_code') | int == 2 %}
  Code2
{% elif states('input_number.last_front_door_code') | int == 3 %}
  Code3
{% elif states('input_number.last_front_door_code') | int == 4 %}
  Code4
{% elif states('input_number.last_front_door_code') | int == 5 %}
  Code5
{% elif states('input_number.last_front_door_code') | int == 6 %}
  Code6
{% elif states('input_number.last_front_door_code') | int == 7 %}
  Code7
{% elif states('input_number.last_front_door_code') | int == 8 %}
  Code8
{% elif states('input_number.last_front_door_code') | int == 9 %}
  Code9
{% else %}
  Error
{% endif %}
mode: single
alias: Front Lock - Lock Code
description: ''
trigger:
  - platform: event
    event_type: zwave_js_notification
condition:
  - condition: template
    value_template: '{{ trigger.event.data.device_id == ''445eaa0e224212800af3'' }}'
  - condition: template
    value_template: '{{ trigger.event.data.event == 6 }}'
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.last_front_door_code
    data:
      value: '{{trigger.event.data.parameters.userId | int}}'
  - service: input_text.set_value
    target: 
      entity_id: input_text.front_lock_user
    data:
      value: >
        {% if states('input_number.last_front_door_code') | int == 1 %}
          Code1
        {% elif states('input_number.last_front_door_code') | int == 2 %}
          Code2
        {% elif states('input_number.last_front_door_code') | int == 3 %}
          Code3
        {% elif states('input_number.last_front_door_code') | int == 4 %}
          Code4
        {% elif states('input_number.last_front_door_code') | int == 5 %}
          Code5
        {% elif states('input_number.last_front_door_code') | int == 6 %}
          Code6
        {% elif states('input_number.last_front_door_code') | int == 7 %}
          Code7
        {% elif states('input_number.last_front_door_code') | int == 8 %}
          Code8
        {% elif states('input_number.last_front_door_code') | int == 9 %}
          Code9
        {% else %}
          Error
        {% endif %}
mode: single
1 Like

Thank you, thank you…Now I have to figure out where I went wrong. Thanks for taking time to help.

It was mainly the indentation of the if/else cases for the input_text.front_lock_user template.