Weird…I know I had a thread on here somewhere with the entire script and frontend yaml laid out, but I can’t find it anywhere…I’ll do my best to re-create it here:
This does require creating some helpers (amount depends on how many users and locks you have). Below is the script I put in a package (note: I have three locks but paired it down to two for this example)
script:
## Front Door
set_lock_frontdoor_code:
alias: Set Front Door Lock Code
sequence:
- service: zwave_js.set_lock_usercode
target:
entity_id: lock.lock_front_door
data:
usercode: >
{{ "%04d" % states('input_text.front_door_code_' ~ states('input_select.code_slot')) | int(0) }}
code_slot: '{{ states("input_select.code_slot") | int }}'
mode: single
icon: mdi:arrow-right-bold-circle
delete_lock_frontdoor_code:
alias: Delete Front Lock Code
sequence:
- service: zwave_js.clear_lock_usercode
target:
entity_id: lock.lock_front_door
data:
code_slot: '{{ states("input_select.code_slot") | int }}'
- service: input_text.set_value
data:
entity_id: >
{% if is_state('input_select.code_slot','01') %}
input_text.front_door_code_01
{% elif is_state('input_select.code_slot','02') %}
input_text.front_door_code_02
{% elif is_state('input_select.code_slot','03') %}
input_text.front_door_code_03
{% elif is_state('input_select.code_slot','04') %}
input_text.front_door_code_04
{% elif is_state('input_select.code_slot','05') %}
input_text.front_door_code_05
{% elif is_state('input_select.code_slot','06') %}
input_text.front_door_code_06
{% endif %}
value: ""
- service: input_text.set_value
data:
entity_id: >
{% if is_state('input_select.code_slot','01') %}
input_text.code_slot_front_user_01
{% elif is_state('input_select.code_slot','02') %}
input_text.code_slot_front_user_02
{% elif is_state('input_select.code_slot','03') %}
input_text.code_slot_front_user_03
{% elif is_state('input_select.code_slot','04') %}
input_text.code_slot_front_user_04
{% elif is_state('input_select.code_slot','05') %}
input_text.code_slot_front_user_05
{% elif is_state('input_select.code_slot','06') %}
input_text.code_slot_front_user_06
{% endif %}
value: ""
mode: single
icon: mdi:delete-circle
##Back Door
set_lock_bckdoor_code:
alias: Set Back Door Lock Code
sequence:
- service: zwave_js.set_lock_usercode
target:
entity_id: lock.lock_back_door
data:
usercode: >
{{ "%04d" % states('input_text.bck_lock_code_' ~ states('input_select.code_slot')) | int(0) }}
code_slot: '{{ states("input_select.code_slot") | int }}'
mode: single
icon: mdi:arrow-right-bold-circle
delete_lock_bckdoor_code:
alias: Delete Back Lock Code
sequence:
- service: zwave_js.clear_lock_usercode
target:
entity_id: lock.lock_back_door
data:
code_slot: '{{ states("input_select.code_slot") | int }}'
- service: input_text.set_value
data: #user name
entity_id: >
{% if is_state('input_select.code_slot','01') %}
input_text.code_slot_bck_user_01
{% elif is_state('input_select.code_slot','02') %}
input_text.code_slot_bck_user_02
{% elif is_state('input_select.code_slot','03') %}
input_text.code_slot_bck_user_03
{% elif is_state('input_select.code_slot','04') %}
input_text.code_slot_bck_user_04
{% elif is_state('input_select.code_slot','05') %}
input_text.code_slot_bck_user_05
{% elif is_state('input_select.code_slot','06') %}
input_text.code_slot_bck_user_06
{% endif %}
value: ""
- service: input_text.set_value
data: #user code
entity_id: >
{% if is_state('input_select.code_slot','01') %}
input_text.bck_lock_code_01
{% elif is_state('input_select.code_slot','02') %}
input_text.bck_lock_code_02
{% elif is_state('input_select.code_slot','03') %}
input_text.bck_lock_code_03
{% elif is_state('input_select.code_slot','04') %}
input_text.bck_lock_code_04
{% elif is_state('input_select.code_slot','05') %}
input_text.bck_lock_code_05
{% elif is_state('input_select.code_slot','06') %}
input_text.bck_lock_code_06
{% endif %}
value: ""
mode: single
icon: mdi:delete-circle
Helpers needed for each door and lock:
input_text.yourlock_lock_code_01 (one for each code 01 - ??)
input_text.code_slot_yourlock_user_01 (one for each user (01 - ??)
For example…If you want to have up to six slots, then you would need a total of 12 helpers (6 of each) for EACH lock.
input_select.code_slot (this help just tells the script how many codes you want for each lock in the drop down.
here is an example:
The yaml for the frontend is pretty straight forward:
- theme: Google Dark Theme Mod
title: LOCKS
path: locks
type: custom:grid-layout
badges: []
cards:
- type: horizontal-stack
cards:
- cards:
- type: entities
title: Front Door Lock Codes
entities:
- input_select.code_slot
- type: custom:state-switch
entity: input_select.code_slot
states:
'01':
cards: null
type: entities
entities:
- entity: input_text.code_slot_front_user_01
- entity: input_text.front_door_code_01
- entity: script.set_lock_frontdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_frontdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_frontdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_frontdoor_code
confirmation:
text: Delete the lock code for this slot?
'02':
cards: null
type: entities
entities:
- entity: input_text.code_slot_front_user_02
- entity: input_text.front_door_code_02
- entity: script.set_lock_frontdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_frontdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_frontdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_frontdoor_code
confirmation:
text: Delete the lock code for this slot?
'03':
cards: null
type: entities
entities:
- entity: input_text.code_slot_front_user_03
- entity: input_text.front_door_code_03
- entity: script.set_lock_frontdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_frontdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_frontdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_frontdoor_code
confirmation:
text: Delete the lock code for this slot?
'04':
cards: null
type: entities
entities:
- entity: input_text.code_slot_front_user_04
- entity: input_text.front_door_code_04
- entity: script.set_lock_frontdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_frontdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_frontdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_frontdoor_code
confirmation:
text: Delete the lock code for this slot?
'05':
cards: null
type: entities
entities:
- entity: input_text.code_slot_front_user_05
- entity: input_text.front_door_code_05
- entity: script.set_lock_frontdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_frontdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_frontdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_frontdoor_code
confirmation:
text: Delete the lock code for this slot?
'06':
cards: null
type: entities
entities:
- entity: input_text.code_slot_front_user_06
- entity: input_text.front_door_code_06
- entity: script.set_lock_frontdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_frontdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_frontdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_frontdoor_code
confirmation:
text: Delete the lock code for this slot?
type: vertical-stack
- cards:
- type: entities
title: Back Door Lock Codes
entities:
- input_select.code_slot
- type: custom:state-switch
entity: input_select.code_slot
states:
'01':
cards: null
type: entities
entities:
- entity: input_text.code_slot_bck_user_01
- entity: input_text.bck_lock_code_01
- entity: script.set_lock_bckdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_bckdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_bckdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_bckdoor_code
confirmation:
text: Delete the lock code for this slot?
'02':
cards: null
type: entities
entities:
- entity: input_text.code_slot_bck_user_02
- entity: input_text.bck_lock_code_02
- entity: script.set_lock_bckdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_bckdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_bckdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_bckdoor_code
confirmation:
text: Delete the lock code for this slot?
'03':
cards: null
type: entities
entities:
- entity: input_text.code_slot_bck_user_03
- entity: input_text.bck_lock_code_03
- entity: script.set_lock_bckdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_bckdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_bckdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_bckdoor_code
confirmation:
text: Delete the lock code for this slot?
'04':
cards: null
type: entities
entities:
- entity: input_text.code_slot_bck_user_04
- entity: input_text.bck_lock_code_04
- entity: script.set_lock_bckdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_bckdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_bckdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_bckdoor_code
confirmation:
text: Delete the lock code for this slot?
'05':
cards: null
type: entities
entities:
- entity: input_text.code_slot_bck_user_05
- entity: input_text.bck_lock_code_05
- entity: script.set_lock_bckdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_bckdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_bckdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_bckdoor_code
confirmation:
text: Delete the lock code for this slot?
'06':
cards: null
type: entities
entities:
- entity: input_text.code_slot_bck_user_06
- entity: input_text.bck_lock_code_06
- entity: script.set_lock_bckdoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_bckdoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_bckdoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_bckdoor_code
confirmation:
text: Delete the lock code for this slot?
type: vertical-stack
- cards:
- type: entities
title: Garage Door Lock Codes
entities:
- input_select.code_slot
- type: custom:state-switch
entity: input_select.code_slot
states:
'01':
cards: null
type: entities
entities:
- entity: input_text.code_slot_garage_user_01
- entity: input_text.garage_door_code_01
- entity: script.set_lock_garagedoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_garagedoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_garagedoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_garagedoor_code
confirmation:
text: Delete the lock code for this slot?
'02':
cards: null
type: entities
entities:
- entity: input_text.code_slot_garage_user_02
- entity: input_text.garage_door_code_02
- entity: script.set_lock_garagedoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_garagedoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_garagedoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_garagedoor_code
confirmation:
text: Delete the lock code for this slot?
'03':
cards: null
type: entities
entities:
- entity: input_text.code_slot_garage_user_03
- entity: input_text.garage_door_code_03
- entity: script.set_lock_garagedoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_garagedoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_garagedoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_garagedoor_code
confirmation:
text: Delete the lock code for this slot?
'04':
cards: null
type: entities
entities:
- entity: input_text.code_slot_garage_user_04
- entity: input_text.garage_door_code_04
- entity: script.set_lock_garagedoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_garagedoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_garagedoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_garagedoor_code
confirmation:
text: Delete the lock code for this slot?
'05':
cards: null
type: entities
entities:
- entity: input_text.code_slot_garage_user_05
- entity: input_text.garage_door_code_05
- entity: script.set_lock_garagedoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_garagedoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_garagedoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_garagedoor_code
confirmation:
text: Delete the lock code for this slot?
'06':
cards: null
type: entities
entities:
- entity: input_text.code_slot_garage_user_06
- entity: input_text.garage_door_code_06
- entity: script.set_lock_garagedoor_code
action_name: Set
type: button
name: Set Lock Code
tap_action:
action: call-service
service: script.set_lock_garagedoor_code
confirmation:
text: Change the lock code for this slot?
- entity: script.delete_lock_garagedoor_code
action_name: Delete
type: button
name: Delete Lock Code
tap_action:
action: call-service
service: script.delete_lock_garagedoor_code
confirmation:
text: Delete the lock code for this slot?
type: vertical-stack
It looks cumbersome, but once put together runs pretty smoothly…It also isn’t as bloat-y as Keymaster. Keymaster is a great script, just way more than I needed. Hope this helps!