Here’s your fix replace the automations as listed:
- alias: BackDoor Add Code
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
trigger:
entity_id: binary_sensor.active_backdoor_1, binary_sensor.active_backdoor_2
platform: state
to: 'on'
action:
- service: lock.set_usercode
data_template:
node_id: >-
{{states.lock.schlage_allegion_be469_touchscreen_deadbolt_backdoor.attributes.node_id}}
code_slot: >-
{% set object_id = trigger.to_state.object_id %}
{% set index = -1 %}
{% set code_slot = object_id[index:] %}
{{ code_slot }}
usercode: >-
{% set object_id = trigger.to_state.object_id %}
{% set index = -1 %}
{% set code_slot = object_id[index:] %}
{% set codetext = 'backdoor_pin_' + code_slot | string %}
{% set code = states['input_text'][codetext].state %}
{{ code | string }}
and
- alias: BackDoor Clear Code
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
trigger:
entity_id: binary_sensor.active_backdoor_1, binary_sensor.active_backdoor_2
platform: state
to: 'off'
action:
# - service: lock.clear_usercode
# data_template:
# node_id: >-
# {{states.lock.schlage_allegion_be469_touchscreen_deadbolt_backdoor.attributes.node_id}}
# code_slot: >-
# {% set object_id = trigger.to_state.object_id %}
# {% set index = 17 %}
# {% set code_slot = object_id[inex:] %}
# {{ code_slot }}
- service: lock.set_usercode
data_template:
node_id: >-
{{states.lock.schlage_allegion_be469_touchscreen_deadbolt_backdoor.attributes.node_id}}
code_slot: >-
{% set index = -1 %}
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = object_id[index:] %}
{{ code_slot }}
usercode: >-
{{ range(1000, 9999) | random | int }}
Should fix you right up.