sparklee
(Lee)
November 4, 2021, 7:13pm
1
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
tom_l
November 4, 2021, 10:57pm
2
See how your condition is highlighted in red?
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
sparklee
(Lee)
November 4, 2021, 11:31pm
3
That was an error when I posted it, but the same error is there even after adding the quote.
finity
November 4, 2021, 11:35pm
4
you also have an extra quote at the beginning of this line above.
sparklee
(Lee)
November 4, 2021, 11:39pm
5
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 … "
^
sparklee
(Lee)
November 4, 2021, 11:45pm
7
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
tom_l
November 4, 2021, 11:49pm
8
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
sparklee
(Lee)
November 4, 2021, 11:56pm
9
Thank you, thank you…Now I have to figure out where I went wrong. Thanks for taking time to help.
tom_l
November 5, 2021, 12:05am
10
It was mainly the indentation of the if/else cases for the input_text.front_lock_user
template.