Okay, did some digging and found it under:
/config/packages/lock-manager/frontdoor/frontdoor_lock_manager_common.yaml
Is that the right one?
Looks like it. This discussion was had just a few posts before yours. Click on the link in my quote.
Get it working?
Thanks for following up @mcoleman001. Unfortunately it didnât work. I updated the file, restarted HA, and used a code to unlock the door but still no notifications. When I have some more time, Iâll dig into the logs.
So here is whatâs coming up in the log:
2020-04-21 15:57:35 ERROR (MainThread) [homeassistant.components.automation] FrontDoor Notifications: Error executing script. Service not found for call_service at pos 1: Unable to find service script/conditional_notify
2020-04-21 15:57:35 ERROR (MainThread) [homeassistant.components.automation] FrontDoor Notifications: Error executing script. Service not found for call_service at pos 1: Unable to find service script/conditional_notify
Here is whatâs in /config/packages/lock-manager/frontdoor/frontdoor_lock_manager_common.yaml
##################################################
################ COMMON ENTITIES ###############
##################################################
############### input_boolean: #################
input_boolean:
frontdoor_lock_notifications:
name: "Lock Notifications"
frontdoor_dooraccess_notifications:
name: "Door Notifications"
frontdoor_garageacess_notifications:
name: "Garage Notifications"
frontdoor_reset_lock:
name: "frontdoor reset lock"
############## binary_sensor: ####################
binary_sensor:
- platform: template
sensors:
dummy_sensor_factory_access_control_dummy_sensor:
value_template: "{{ is_state('sensor.dummy_sensor_factory_access_control_dummy_sensor', '22') }}"
friendly_name: "dummy_sensor"
device_class: door
dummy_sensor_factory_burglar_dummy_sensor:
value_template: "{{ is_state('sensor.dummy_sensor_factory_burglar_dummy_sensor', '3') }}"
friendly_name: "dummy_sensor Sensor Tamper"
device_class: safety
################### sensor: ####################
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'date_time_iso'
- 'time_date'
- 'time_utc'
- 'beat'
- platform: template
sensors:
frontdoor_statusreport:
friendly_name: 'frontdoor Status Report'
value_template: >
{% set number = states('sensor.schlage_allegion_be468_touchscreen_deadbolt_alarm_level_frontdoor') %}
{% set alarm_type_value = states('sensor.schlage_allegion_be468_touchscreen_deadbolt_alarm_type_frontdoor') %}
{% if ((as_timestamp(now())-as_timestamp(states.lock.schlage_allegion_be468_touchscreen_deadbolt_locked_frontdoor.last_changed)) < 15 and (as_timestamp(now())-as_timestamp(states.sensor.schlage_allegion_be468_touchscreen_deadbolt_alarm_type_frontdoor.last_changed)) > 15) %}
{% if (states.lock.schlage_allegion_be468_touchscreen_deadbolt_locked_frontdoor.state) == 'locked' %}
{% set alarm_type_value = '24' %}
{% elif (states.lock.schlage_allegion_be468_touchscreen_deadbolt_locked_frontdoor.state) == 'unlocked' %}
{% set alarm_type_value = '25' %}
{% endif %}
{% endif %}
{% set alarm_type_general_actions = {
'0':'No Status Reported',
'9':'Lock Jammed',
'17':'Keypad Lock Jammed',
'21':'Manual Lock',
'22':'Manual Unlock',
'23':'HA Lock Jammed',
'24':'HA Lock',
'25':'HA Unlock',
'26':'Auto Lock Jammed',
'27':'Auto Lock',
'32':'All Codes Deleted',
'161':'Bad Code Entered',
'167':'Battery Low',
'168':'Battery Critical',
'169':'Battery Too Low To Operate Lock' } %}
{% set alarm_type_lock_actions = {
'18':'Keypad Lock',
'19':'Keypad Unlock',
'162':'Lock Code Attempt Outside of Schedule' } %}
{% set alarm_type_code_actions = {
'33':'Code Deleted',
'112':'Code Changed',
'113':'Duplicate Code' } %}
{% if alarm_type_value in alarm_type_code_actions %}
{{alarm_type_value}};{{ alarm_type_code_actions[alarm_type_value] }};{{number}}
{% elif alarm_type_value in alarm_type_lock_actions %}
{{alarm_type_value}};{{ alarm_type_lock_actions[alarm_type_value] }};{{number}}
{% elif alarm_type_value in alarm_type_general_actions %}
{{alarm_type_value}};{{ alarm_type_general_actions[alarm_type_value] }}
{% else %}
{{-1}};Unknown Alarm Type Value {{ states('sensor.schlage_allegion_be468_touchscreen_deadbolt_alarm_type_frontdoor') }}
{% endif %}
################### script : ####################
script:
frontdoor_reset_lock:
sequence:
- service: script.frontdoor_manual_notify
data_template:
title: "reset"
message: "frontdoor"
frontdoor_conditional_notify:
sequence:
- condition: template
value_template: >-
{% set inputbool = boolean %}
{% if states(inputbool) == 'on'%}
true
{% else %}
false
{% endif %}
- service: script.frontdoor_manual_notify
data_template:
title: "{{title}}"
message: "{{message}}"
frontdoor_manual_notify:
sequence:
- service: notify.notify
data_template:
title: "{{title}}"
message: "{{message}}"
######################################################
################### automation: ####################
automation:
- alias: FrontDoor Notifications
trigger:
platform: state
entity_id: sensor.frontdoor_statusreport
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
- condition: template
value_template: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% if (a|length) != 3 or (a[2] == "0") %}
{{ true }}
{% else %}
{{ true }}
{% endif %}
action:
- service: script.conditional_notify
data_template:
boolean: input_boolean.frontdoor_lock_notifications
title: "Sensor Status Report"
message: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% set msg = "ID:" + a[0] + " MSG:" + a[1] %}
{% if (a|length) == 3 %}
{% set msg = msg + " SLOT:" + a[2] %}
{% endif %}
{{ a[1] }}
- alias: FrontDoor User Notifications
trigger:
platform: state
entity_id: sensor.frontdoor_statusreport
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
- condition: template
value_template: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% if (a|length) == 3 and (a[2] | int > 0) %}
{{ true }}
{% else %}
{{ false }}
{% endif %}
- condition: template
value_template: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% set entity_id = 'notify_frontdoor_' + a[2] %}
{% set notify = states['input_boolean'][entity_id].state %}
{{ notify == "on" }}
action:
- service: script.manual_notify
data_template:
title: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{{ a[1] }}
message: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% set entity_id = 'input_text.frontdoor_name_' + a[2] %}
{% set user = states(entity_id) %}
{{ user }}
###############################
- alias: dummy_sensor Sensor Close
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
trigger:
entity_id: binary_sensor.dummy_sensor_factory_access_control_dummy_sensor
platform: state
to: 'off'
action:
- service: script.conditional_notify
data_template:
boolean: input_boolean.frontdoor_dooraccess_notifications
title: "dummy_sensor"
message: "Closed"
- alias: dummy_sensor Sensor Opened
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
trigger:
entity_id: binary_sensor.dummy_sensor_factory_access_control_dummy_sensor
platform: state
to: 'on'
action:
- service: script.conditional_notify
data_template:
boolean: input_boolean.frontdoor_dooraccess_notifications
title: "dummy_sensor"
message: "Opened"
- alias: FrontDoor Add Code
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
trigger:
entity_id: binary_sensor.active_frontdoor_1, binary_sensor.active_frontdoor_2, binary_sensor.active_frontdoor_3, binary_sensor.active_frontdoor_4, binary_sensor.active_frontdoor_5, binary_sensor.active_frontdoor_6
platform: state
to: 'on'
action:
- service: lock.set_usercode
data_template:
node_id: >-
{{states.lock.schlage_allegion_be468_touchscreen_deadbolt_locked_frontdoor.attributes.node_id}}
code_slot: >-
{% set object_id = trigger.to_state.object_id %}
{% set index = 17 %}
{% set code_slot = object_id[index:] %}
{{ code_slot }}
usercode: >-
{% set object_id = trigger.to_state.object_id %}
{% set index = 17 %}
{% set code_slot = object_id[index:] %}
{% set codetext = 'frontdoor_pin_' + code_slot | string %}
{% set code = states['input_text'][codetext].state %}
{{ code | string }}
- alias: FrontDoor Update Code
trigger:
entity_id: input_text.frontdoor_pin_1, input_text.frontdoor_pin_2, input_text.frontdoor_pin_3, input_text.frontdoor_pin_4, input_text.frontdoor_pin_5, input_text.frontdoor_pin_6
platform: state
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
- condition: template
value_template: >-
{% set object_id = trigger.to_state.object_id %}
{% set index = 14 %}
{% set code_slot = object_id[index:] %}
{% set b = 'input_boolean.enabled_frontdoor_' + code_slot | string %}
{{ is_state(b, 'on') and (trigger.from_state.state != trigger.to_state.state)}}
action:
- service: persistent_notification.create
data_template:
title: "frontdoor LOCK MANAGER"
message: >-
{% set object_id = trigger.to_state.object_id %}
{% set index = 14 %}
{% set code_slot = object_id[index:] %}
{{ 'You changed the PIN for code ' + code_slot | string + '. Please enable it in order to make it active.'}}
- service: input_boolean.turn_off
data_template:
entity_id: >-
{% set object_id = trigger.to_state.object_id %}
{% set index = 14 %}
{% set code_slot = object_id[index:] %}
{{ 'input_boolean.enabled_frontdoor_' + code_slot | string }}
- alias: Reset FrontDoor
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
trigger:
entity_id: input_boolean.frontdoor_reset_lock
platform: state
from: 'off'
to: 'on'
action:
- service: script.frontdoor_reset_lock
- service: input_boolean.turn_off
entity_id: input_boolean.frontdoor_reset_lock
- alias: FrontDoor Clear Code
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
trigger:
entity_id: binary_sensor.active_frontdoor_1, binary_sensor.active_frontdoor_2, binary_sensor.active_frontdoor_3, binary_sensor.active_frontdoor_4, binary_sensor.active_frontdoor_5, binary_sensor.active_frontdoor_6
platform: state
to: 'off'
action:
# - service: lock.clear_usercode
# data_template:
# node_id: >-
# {{states.lock.schlage_allegion_be468_touchscreen_deadbolt_locked_frontdoor.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_be468_touchscreen_deadbolt_locked_frontdoor.attributes.node_id}}
code_slot: >-
{% set index = 17 %}
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = object_id[index:] %}
{{ code_slot }}
usercode: >-
{{ range(1000, 9999) | random | int }}
- alias: FrontDoor Decrement Access Count
trigger:
platform: state
entity_id: sensor.frontdoor_statusreport
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
- condition: template
value_template: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% if (a|length) == 3 and (a[2] | int > 0) %}
{{ (a[0] | int == 19) }}
{% else %}
{{ false }}
{% endif %}
action:
- service: input_number.decrement
data_template:
entity_id: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{{ 'input_number.accesscount_frontdoor_' + a[2] }}
Now if I go to developer tools and manually call script.frontdoor_manual_notify it works, but script.frontdoor_conditional_notify does not.
Any ideas how to fix, this or further narrow it down?
Did you ever get this working? I am having the exact same issue.
################### automation: ####################
automation:
- alias: FrontDoor Notifications
trigger:
platform: state
entity_id: sensor.frontdoor_statusreport
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
- condition: template
value_template: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% if (a|length) != 3 or (a[2] == "0") %}
{{ true }}
{% else %}
{{ true }}
{% endif %}
action:
- service: script.conditional_notify
data_template:
boolean: input_boolean.frontdoor_lock_notifications
title: "Sensor Status Report"
message: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% set msg = "ID:" + a[0] + " MSG:" + a[1] %}
{% if (a|length) == 3 %}
{% set msg = msg + " SLOT:" + a[2] %}
{% endif %}
{{ a[1] }}
You need to adjust the service after the action like so:
action:
- service: script.frontdoor_conditional_notify
data_template:
boolean: input_boolean.frontdoor_lock_notifications
title: "Sensor Status Report"
message: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% set msg = "ID:" + a[0] + " MSG:" + a[1] %}
{% if (a|length) == 3 %}
{% set msg = msg + " SLOT:" + a[2] %}
{% endif %}
{{ a[1] }}
Also:
- alias: FrontDoor User Notifications
trigger:
platform: state
entity_id: sensor.frontdoor_statusreport
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
- condition: template
value_template: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% if (a|length) == 3 and (a[2] | int > 0) %}
{{ true }}
{% else %}
{{ false }}
{% endif %}
- condition: template
value_template: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% set entity_id = 'notify_frontdoor_' + a[2] %}
{% set notify = states['input_boolean'][entity_id].state %}
{{ notify == "on" }}
action:
- service: script.manual_notify
data_template:
title: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{{ a[1] }}
message: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% set entity_id = 'input_text.frontdoor_name_' + a[2] %}
{% set user = states(entity_id) %}
{{ user }}
Needs a modification to:
action:
- service: script.frontdoor_manual_notify
data_template:
title: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{{ a[1] }}
message: >-
{% set report = states.sensor.frontdoor_statusreport.state %}
{% set a = report.split(';') %}
{% set entity_id = 'input_text.frontdoor_name_' + a[2] %}
{% set user = states(entity_id) %}
{{ user }}
Post your packages/lock-manager/frontdoor/frontdoor_lock_manager_common.yaml
file for help.
Thank you @firstof9. I made the changes and will give it a test when I get home this afternoon. The script.sh may need to be updated, to prevent this from happening for others.
Yes, that did the trick, thank you. Iâm very excited that I got it working. If possible I would suggest that the notifications include who locked/unlocked the door.
Based on what Iâm reading from the script, it should notify you of who unlocked/locked the door.
Strange, I went back to do it again so I could send you a screenshot but this time it did send the User. Thanks anyway.
No, unfortunately â I ended up re-installing hassio to fix everything. Also, even with just 3 lock widgets it dramatically slowed things down, so Iâll probably look for other options for right nowâŚ
Think I am getting closer to having this working. I attempted to set a user code in slot one through the gui and here is the error messages in the logs:
Adding a code:
BackDoor Add Code: Error executing script. Unexpected error for call_service at pos 1: Error rendering data template: str: Invalid entity ID âinput_text.backdoor_pin_â
Trying to clear a code:
BackDoor Clear Code: Error executing script. Invalid data for call_service at pos 1: expected int for dictionary value @ data[âcode_slotâ]
Using lock.set_usercode in states works fine. No errors there.
Post your backdoor.yaml
Hopefully this is what you are looking for
##################################################
################ COMMON ENTITIES ###############
##################################################
############### input_boolean: #################
input_boolean:
backdoor_lock_notifications:
name: "Lock Notifications"
backdoor_dooraccess_notifications:
name: "Door Notifications"
backdoor_garageacess_notifications:
name: "Garage Notifications"
backdoor_reset_lock:
name: "backdoor reset lock"
############## binary_sensor: ####################
binary_sensor:
- platform: template
sensors:
schlage_allegion_be469_touchscreen_deadbolt_access_control_backdoor:
value_template: "{{ is_state('sensor.schlage_allegion_be469_touchscreen_deadbolt_access_control_backdoor', '22') }}"
friendly_name: "BackDoor"
device_class: door
schlage_allegion_be469_touchscreen_deadbolt_burglar_backdoor:
value_template: "{{ is_state('sensor.schlage_allegion_be469_touchscreen_deadbolt_burglar_backdoor', '3') }}"
friendly_name: "BackDoor Sensor Tamper"
device_class: safety
################### sensor: ####################
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'date_time_iso'
- 'time_date'
- 'time_utc'
- 'beat'
- platform: template
sensors:
backdoor_statusreport:
friendly_name: 'backdoor Status Report'
value_template: >
{% set number = states('sensor.schlage_allegion_be469_touchscreen_deadbolt_alarm_level_backdoor') %}
{% set alarm_type_value = states('sensor.schlage_allegion_be469_touchscreen_deadbolt_alarm_type_backdoor') %}
{% if ((as_timestamp(now())-as_timestamp(states.lock.schlage_allegion_be469_touchscreen_deadbolt_backdoor.last_changed)) < 15 and (as_timestamp(now())-as_timestamp(states.sensor.schlage_allegion_be469_touchscreen_deadbolt_alarm_type_backdoor.last_changed)) > 15) %}
{% if (states.lock.schlage_allegion_be469_touchscreen_deadbolt_locked_backdoor.state) == 'locked' %}
{% set alarm_type_value = '24' %}
{% elif (states.lock.schlage_allegion_be469_touchscreen_deadbolt_locked_backdoor.state) == 'unlocked' %}
{% set alarm_type_value = '25' %}
{% endif %}
{% endif %}
{% set alarm_type_general_actions = {
'0':'No Status Reported',
'9':'Lock Jammed',
'17':'Keypad Lock Jammed',
'21':'Manual Lock',
'22':'Manual Unlock',
'23':'HA Lock Jammed',
'24':'HA Lock',
'25':'HA Unlock',
'26':'Auto Lock Jammed',
'27':'Auto Lock',
'32':'All Codes Deleted',
'161':'Bad Code Entered',
'167':'Battery Low',
'168':'Battery Critical',
'169':'Battery Too Low To Operate Lock' } %}
{% set alarm_type_lock_actions = {
'18':'Keypad Lock',
'19':'Keypad Unlock',
'162':'Lock Code Attempt Outside of Schedule' } %}
{% set alarm_type_code_actions = {
'33':'Code Deleted',
'112':'Code Changed',
'113':'Duplicate Code' } %}
{% if alarm_type_value in alarm_type_code_actions %}
{{alarm_type_value}};{{ alarm_type_code_actions[alarm_type_value] }};{{number}}
{% elif alarm_type_value in alarm_type_lock_actions %}
{{alarm_type_value}};{{ alarm_type_lock_actions[alarm_type_value] }};{{number}}
{% elif alarm_type_value in alarm_type_general_actions %}
{{alarm_type_value}};{{ alarm_type_general_actions[alarm_type_value] }}
{% else %}
{{-1}};Unknown Alarm Type Value {{ states('sensor.schlage_allegion_be469_touchscreen_deadbolt_alarm_type_backdoor') }}
{% endif %}
################### script : ####################
script:
backdoor_reset_lock:
sequence:
- service: script.backdoor_manual_notify
data_template:
title: "reset"
message: "backdoor"
backdoor_conditional_notify:
sequence:
- condition: template
value_template: >-
{% set inputbool = boolean %}
{% if states(inputbool) == 'on'%}
true
{% else %}
false
{% endif %}
- service: script.backdoor_manual_notify
data_template:
title: "{{title}}"
message: "{{message}}"
backdoor_manual_notify:
sequence:
- service: notify.my_devices
data_template:
title: "{{title}}"
message: "{{message}}"
######################################################
################### automation: ####################
automation:
- alias: BackDoor Notifications
trigger:
platform: state
entity_id: sensor.backdoor_statusreport
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
- condition: template
value_template: >-
{% set report = states.sensor.backdoor_statusreport.state %}
{% set a = report.split(';') %}
{% if (a|length) != 3 or (a[2] == "0") %}
{{ true }}
{% else %}
{{ true }}
{% endif %}
action:
- service: script.conditional_notify
data_template:
boolean: input_boolean.backdoor_lock_notifications
title: "Sensor Status Report"
message: >-
{% set report = states.sensor.backdoor_statusreport.state %}
{% set a = report.split(';') %}
{% set msg = "ID:" + a[0] + " MSG:" + a[1] %}
{% if (a|length) == 3 %}
{% set msg = msg + " SLOT:" + a[2] %}
{% endif %}
{{ a[1] }}
- alias: BackDoor User Notifications
trigger:
platform: state
entity_id: sensor.backdoor_statusreport
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
- condition: template
value_template: >-
{% set report = states.sensor.backdoor_statusreport.state %}
{% set a = report.split(';') %}
{% if (a|length) == 3 and (a[2] | int > 0) %}
{{ true }}
{% else %}
{{ false }}
{% endif %}
- condition: template
value_template: >-
{% set report = states.sensor.backdoor_statusreport.state %}
{% set a = report.split(';') %}
{% set entity_id = 'notify_backdoor_' + a[2] %}
{% set notify = states['input_boolean'][entity_id].state %}
{{ notify == "on" }}
action:
- service: script.manual_notify
data_template:
title: >-
{% set report = states.sensor.backdoor_statusreport.state %}
{% set a = report.split(';') %}
{{ a[1] }}
message: >-
{% set report = states.sensor.backdoor_statusreport.state %}
{% set a = report.split(';') %}
{% set entity_id = 'input_text.backdoor_name_' + a[2] %}
{% set user = states(entity_id) %}
{{ user }}
###############################
- alias: BackDoor Sensor Close
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
trigger:
entity_id: binary_sensor.schlage_allegion_be469_touchscreen_deadbolt_access_control_backdoor
platform: state
to: 'off'
action:
- service: script.conditional_notify
data_template:
boolean: input_boolean.backdoor_dooraccess_notifications
title: "BackDoor"
message: "Closed"
- alias: BackDoor Sensor Opened
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
trigger:
entity_id: binary_sensor.schlage_allegion_be469_touchscreen_deadbolt_access_control_backdoor
platform: state
to: 'on'
action:
- service: script.conditional_notify
data_template:
boolean: input_boolean.backdoor_dooraccess_notifications
title: "BackDoor"
message: "Opened"
- 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 = 17 %}
{% set code_slot = object_id[index:] %}
{{ code_slot }}
usercode: >-
{% set object_id = trigger.to_state.object_id %}
{% set index = 17 %}
{% set code_slot = object_id[index:] %}
{% set codetext = 'backdoor_pin_' + code_slot | string %}
{% set code = states['input_text'][codetext].state %}
{{ code | string }}
- alias: BackDoor Update Code
trigger:
entity_id: input_text.backdoor_pin_1, input_text.backdoor_pin_2
platform: state
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
- condition: template
value_template: >-
{% set object_id = trigger.to_state.object_id %}
{% set index = 14 %}
{% set code_slot = object_id[index:] %}
{% set b = 'input_boolean.enabled_backdoor_' + code_slot | string %}
{{ is_state(b, 'on') and (trigger.from_state.state != trigger.to_state.state)}}
action:
- service: persistent_notification.create
data_template:
title: "backdoor LOCK MANAGER"
message: >-
{% set object_id = trigger.to_state.object_id %}
{% set index = 14 %}
{% set code_slot = object_id[index:] %}
{{ 'You changed the PIN for code ' + code_slot | string + '. Please enable it in order to make it active.'}}
- service: input_boolean.turn_off
data_template:
entity_id: >-
{% set object_id = trigger.to_state.object_id %}
{% set index = 14 %}
{% set code_slot = object_id[index:] %}
{{ 'input_boolean.enabled_backdoor_' + code_slot | string }}
- alias: Reset BackDoor
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
trigger:
entity_id: input_boolean.backdoor_reset_lock
platform: state
from: 'off'
to: 'on'
action:
- service: script.backdoor_reset_lock
- service: input_boolean.turn_off
entity_id: input_boolean.backdoor_reset_lock
- 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 = 17 %}
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = object_id[index:] %}
{{ code_slot }}
usercode: >-
{{ range(1000, 9999) | random | int }}
- alias: BackDoor Decrement Access Count
trigger:
platform: state
entity_id: sensor.backdoor_statusreport
condition:
- condition: state
entity_id: 'binary_sensor.allow_automation'
state: 'on'
- condition: template
value_template: >-
{% set report = states.sensor.backdoor_statusreport.state %}
{% set a = report.split(';') %}
{% if (a|length) == 3 and (a[2] | int > 0) %}
{{ (a[0] | int == 19) }}
{% else %}
{{ false }}
{% endif %}
action:
- service: input_number.decrement
data_template:
entity_id: >-
{% set report = states.sensor.backdoor_statusreport.state %}
{% set a = report.split(';') %}
{{ 'input_number.accesscount_backdoor_' + a[2] }}
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.
Perfect! That worked! Thank you so much.
Iâm thinking you can go thru your yamls and change any index = whatever
to index = -1
.
Maybe leave this post here for others to use as well.