KeyMaster Z-Wave lock manager and scheduler

It isn’t my code it is all in github address above.

Your code could have typos, or other issues related to your configuration. Posting the link to the source in github does not help troubleshoot your issues. The code works for many others, so it could be something in your config that is causing the problem.

Fair enough here are the 3 ini files. FrontDoor is working the other two are not. The ini file is the only file you modify in this. The rest are auto generated by the setup.sh file in github:

FrontDoor.ini contents

#See README for more information.
[lockmanager]

#number of PINS to setup in lovelace
numcodes=6

#the name or location of the lock you are setting up (no spaces)
lockname="FrontDoor"

#the "lowest common denominator" of the factory lock name.  
lockfactoryname="schlage_allegion_be469zp_connect_smart_deadbolt"

#The name of the (optional) door sensor.
sensorname="front_door"

#the "lowest common denominator" of the factory door sensor name.  
sensorfactoryname="front_door_sensor"

#the Home Assistant EntityID of your (optional) garage door
garageentityid="cover.tess_2"

BackDoor.ini

#See README for more information.
[lockmanager]

#number of PINS to setup in lovelace
numcodes=6

#the name or location of the lock you are setting up (no spaces)
lockname="BackDoor"

#the "lowest common denominator" of the factory lock name.  
lockfactoryname="schlage_be469zp_backdoor"

#The name of the (optional) door sensor.
sensorname="backdoor"

#the "lowest common denominator" of the factory door sensor name.  
sensorfactoryname="backdoor_sensor"

#the Home Assistant EntityID of your (optional) garage door
garageentityid="cover.s2000_2"

Garage.ini

#See README for more information.
[lockmanager]

#number of PINS to setup in lovelace
numcodes=6

#the name or location of the lock you are setting up (no spaces)
lockname="Garage"

#the "lowest common denominator" of the factory lock name.  
lockfactoryname="schlage_allegion_be469zp_connect_smart_deadbolt"

#The name of the (optional) door sensor.
sensorname="garage_door"

#the "lowest common denominator" of the factory door sensor name.  
sensorfactoryname="garage_door_sensor"

#the Home Assistant EntityID of your (optional) garage door
garageentityid="cover.tess_2"

Post the yml files from /homeassistant/packages/lockmanager

I will have to do that in a week when I am back home there are 6 or more per lock that it generates.

Same issue here.

awk: line 9: syntax error at or near [
awk: line 10: syntax error at or near [
awk: line 11: syntax error at or near else
awk: line 12: syntax error at or near [
awk: line 16: syntax error at or near [
lock_manager.ini is incomplete or does not exist
./setup.sh: line 80: ((: i<=: syntax error: operand expected (error token is “<=”)
./setup.sh: line 97: ((: i<=: syntax error: operand expected (error token is “<=”)
creating
mkdir: missing operand
Try ‘mkdir --help’ for more information.
mv: missing destination file operand after ‘*.yaml’
Try ‘mv --help’ for more information.
mv: missing destination file operand after ‘_lovelace’
Try ‘mv --help’ for more information.

I can gladly give you access to the config if you want to try it.

Here is where I fail:

when I run the setup.sh no new folder generate as the github instructions state would.

I am only trying to setup one lock, here is the ini:
FrontDoor.ini:

#See README for more information.
[lockmanager]

#number of PINS to setup in lovelace
numcodes=6

#the name or location of the lock you are setting up (no spaces)
lockname="FrontDoor"

#the "lowest common denominator" of the factory lock name.  
lockfactoryname="kwikset_spectrum_brands_unknown_type_0003_id_0541"

#The name of the (optional) door sensor.
sensorname="frontdoor"

#the "lowest common denominator" of the factory door sensor name.  
sensorfactoryname="lumi_lumi_sensor_magnet_aq2_7c804e04remind"

#the Home Assistant EntityID of your (optional) garage door
garageentityid="cover.garage_door_opener"


I might be overlooking something but I see not yaml files in the directory. There are .txt files. As far as I can tell the only thing edited from the Github is the FrontDoor.ini nothing else was touched.

I assume the lock_manager.txt file is the file you need to see?

if so:


############  input_number:  #####################  
input_number:
  accesscount_LOCKNAME_TEMPLATENUM:
    name: Access Count
    min: 0
    max: 100
    step: 1
    unit_of_measurement: "Openings Left"

#################  input_datetime:  ##############  
input_datetime:
  end_date_LOCKNAME_TEMPLATENUM:
    name: 'End'
    has_time: false
    has_date: true
  start_date_LOCKNAME_TEMPLATENUM:
    name: 'Start'
    has_time: false
    has_date: true

  sun_start_date_LOCKNAME_TEMPLATENUM:
    name: 'Start'
    has_time: true
    has_date: false
  sun_end_date_LOCKNAME_TEMPLATENUM:
    name: 'End'
    has_time: true
    has_date: false

  mon_start_date_LOCKNAME_TEMPLATENUM:
    name: 'Start'
    has_time: true
    has_date: false
  mon_end_date_LOCKNAME_TEMPLATENUM:
    name: 'End'
    has_time: true
    has_date: false

  tue_start_date_LOCKNAME_TEMPLATENUM:
    name: 'Start'
    has_time: true
    has_date: false
  tue_end_date_LOCKNAME_TEMPLATENUM:
    name: 'End'
    has_time: true
    has_date: false

  wed_start_date_LOCKNAME_TEMPLATENUM:
    name: 'Start'
    has_time: true
    has_date: false
  wed_end_date_LOCKNAME_TEMPLATENUM:
    name: 'End'
    has_time: true
    has_date: false

  thu_start_date_LOCKNAME_TEMPLATENUM:
    name: 'Start'
    has_time: true
    has_date: false
  thu_end_date_LOCKNAME_TEMPLATENUM:
    name: 'End'
    has_time: true
    has_date: false

  fri_start_date_LOCKNAME_TEMPLATENUM:
    name: 'Start'
    has_time: true
    has_date: false
  fri_end_date_LOCKNAME_TEMPLATENUM:
    name: 'End'
    has_time: true
    has_date: false

  sat_start_date_LOCKNAME_TEMPLATENUM:
    name: 'Start'
    has_time: true
    has_date: false
  sat_end_date_LOCKNAME_TEMPLATENUM:
    name: 'End'
    has_time: true
    has_date: false


####################  input_text:  ###############  
input_text:
  LOCKNAME_name_TEMPLATENUM:
    name: 'Name'
  LOCKNAME_pin_TEMPLATENUM:
    name: 'PIN'

#################  input_boolean: ################  
input_boolean:
  notify_LOCKNAME_TEMPLATENUM:
    name: 'Notifications'
  daterange_LOCKNAME_TEMPLATENUM:
    name: 'Use Date Range'
  smtwtfs_LOCKNAME_TEMPLATENUM:
    name: 'Use SMTWTFS'
  enabled_LOCKNAME_TEMPLATENUM:
    name: 'Enabled'
  accesslimit_LOCKNAME_TEMPLATENUM:
    name: 'Limit Access Count'
    initial: off
  reset_advanced_LOCKNAME_TEMPLATENUM:
    name: 'Reset Advanaced Options'
    initial: off

  sun_LOCKNAME_TEMPLATENUM:
    name: 'Sunday'
    initial: on

  mon_LOCKNAME_TEMPLATENUM:
    name: 'Monday'
    initial: on

  tue_LOCKNAME_TEMPLATENUM:
    name: 'Tuesday'
    initial: on

  wed_LOCKNAME_TEMPLATENUM:
    name: 'Wednesday'
    initial: on

  thu_LOCKNAME_TEMPLATENUM:
    name: 'Thursday'
    initial: on

  fri_LOCKNAME_TEMPLATENUM:
    name: 'Friday'
    initial: on

  sat_LOCKNAME_TEMPLATENUM:
    name: 'Saturday'
    initial: on

################  automation: #################  
automation:

- alias: reset_advanced_CASE_LOCK_NAME_TEMPLATENUM
  trigger:
    entity_id: input_boolean.reset_advanced_LOCKNAME_TEMPLATENUM
    platform: state
    to: 'on'
  action:
    - service: input_number.set_value
      data_template:
        entity_id: input_number.accesscount_LOCKNAME_TEMPLATENUM
        value: "0"
      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.sun_start_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.sun_end_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.mon_start_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.mon_end_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.tue_start_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.tue_end_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.wed_start_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.wed_end_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.thu_start_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.thu_end_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.fri_start_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.fri_end_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.sat_start_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
    - service: input_datetime.set_datetime
      entity_id: input_datetime.sat_end_date_LOCKNAME_TEMPLATENUM
      data_template:
        time: >
          {{  (("00:00")  | timestamp_custom("%H:%M"))  }}      
          
    - service: input_datetime.set_datetime
      entity_id: input_datetime.start_date_LOCKNAME_TEMPLATENUM
      data_template:
        date: >
          {{  (("1980-01-01")  | timestamp_custom("%Y %m %d"))  }}      
          
    - service: input_datetime.set_datetime
      entity_id: input_datetime.end_date_LOCKNAME_TEMPLATENUM
      data_template:
        date: >
          {{  (("1980-01-01")  | timestamp_custom("%Y %m %d"))  }}      

    - service: input_boolean.turn_off
      entity_id: input_boolean.daterange_LOCKNAME_TEMPLATENUM

    - service: input_boolean.turn_off
      entity_id: input_boolean.accesslimit_LOCKNAME_TEMPLATENUM
      
    - service: input_boolean.turn_off
      entity_id: input_boolean.reset_advanced_LOCKNAME_TEMPLATENUM
      
    - service: input_boolean.turn_on
      entity_id: input_boolean.sun_LOCKNAME_TEMPLATENUM
      
    - service: input_boolean.turn_on
      entity_id: input_boolean.mon_LOCKNAME_TEMPLATENUM
      
    - service: input_boolean.turn_on
      entity_id: input_boolean.tue_LOCKNAME_TEMPLATENUM
      
    - service: input_boolean.turn_on
      entity_id: input_boolean.wed_LOCKNAME_TEMPLATENUM
      
    - service: input_boolean.turn_on
      entity_id: input_boolean.thu_LOCKNAME_TEMPLATENUM
      
    - service: input_boolean.turn_on
      entity_id: input_boolean.fri_LOCKNAME_TEMPLATENUM
      
    - service: input_boolean.turn_on
      entity_id: input_boolean.sat_LOCKNAME_TEMPLATENUM
      
################  binary_sensor: #################  
binary_sensor:

- platform: template
  sensors:

    enabled_LOCKNAME_TEMPLATENUM:
      value_template: "{{ is_state('input_boolean.enabled_LOCKNAME_TEMPLATENUM', 'on') }}"

    daterange_LOCKNAME_TEMPLATENUM:
      value_template: "{{ (is_state('input_boolean.daterange_LOCKNAME_TEMPLATENUM', 'off') or ((states.input_datetime.start_date_LOCKNAME_TEMPLATENUM.attributes.timestamp| int | timestamp_custom('%Y%m%d', False)|int)|string <= now().strftime('%Y%m%d')) and (states.input_datetime.end_date_LOCKNAME_TEMPLATENUM.attributes.timestamp| int | timestamp_custom('%Y%m%d', False)|int)|string >=  now().strftime('%Y%m%d'))}}"

    sun_LOCKNAME_TEMPLATENUM:
      entity_id:
        - sensor.time
        - input_datetime.sun_start_date_LOCKNAME_TEMPLATENUM
        - input_datetime.sun_end_date_LOCKNAME_TEMPLATENUM
      value_template: "{{ ((is_state('input_boolean.sun_LOCKNAME_TEMPLATENUM', 'on'))) and (strptime(states('sensor.date'), '%Y-%m-%d').strftime('%A') == 'Sunday') and ((states.input_datetime.sun_start_date_LOCKNAME_TEMPLATENUM.state  == states.input_datetime.sun_end_date_LOCKNAME_TEMPLATENUM.state) or ((states('sensor.time') >= states('input_datetime.sun_start_date_LOCKNAME_TEMPLATENUM')[0:5]) and (states('sensor.time') <= states('input_datetime.sun_end_date_LOCKNAME_TEMPLATENUM')[0:5]))) }}"

    mon_LOCKNAME_TEMPLATENUM:
      entity_id:
        - sensor.time
        - input_datetime.mon_start_date_LOCKNAME_TEMPLATENUM
        - input_datetime.mon_end_date_LOCKNAME_TEMPLATENUM
      value_template: "{{ ((is_state('input_boolean.mon_LOCKNAME_TEMPLATENUM', 'on'))) and (strptime(states('sensor.date'), '%Y-%m-%d').strftime('%A') == 'Monday') and ((states.input_datetime.mon_start_date_LOCKNAME_TEMPLATENUM.state  == states.input_datetime.mon_end_date_LOCKNAME_TEMPLATENUM.state) or ((states('sensor.time') >= states('input_datetime.mon_start_date_LOCKNAME_TEMPLATENUM')[0:5]) and (states('sensor.time') <= states('input_datetime.mon_end_date_LOCKNAME_TEMPLATENUM')[0:5]))) }}"

    tue_LOCKNAME_TEMPLATENUM:
      entity_id:
        - sensor.time
        - input_datetime.tue_start_date_LOCKNAME_TEMPLATENUM
        - input_datetime.tue_end_date_LOCKNAME_TEMPLATENUM
      value_template: "{{ ((is_state('input_boolean.tue_LOCKNAME_TEMPLATENUM', 'on'))) and (strptime(states('sensor.date'), '%Y-%m-%d').strftime('%A') == 'Tuesday') and ((states.input_datetime.tue_start_date_LOCKNAME_TEMPLATENUM.state  == states.input_datetime.tue_end_date_LOCKNAME_TEMPLATENUM.state) or ((states('sensor.time') >= states('input_datetime.tue_start_date_LOCKNAME_TEMPLATENUM')[0:5]) and (states('sensor.time') <= states('input_datetime.tue_end_date_LOCKNAME_TEMPLATENUM')[0:5]))) }}"

    wed_LOCKNAME_TEMPLATENUM:
      entity_id:
        - sensor.time
        - input_datetime.wed_start_date_LOCKNAME_TEMPLATENUM
        - input_datetime.wed_end_date_LOCKNAME_TEMPLATENUM
      value_template: "{{ ((is_state('input_boolean.wed_LOCKNAME_TEMPLATENUM', 'on'))) and (strptime(states('sensor.date'), '%Y-%m-%d').strftime('%A') == 'Wednesday') and ((states.input_datetime.wed_start_date_LOCKNAME_TEMPLATENUM.state  == states.input_datetime.wed_end_date_LOCKNAME_TEMPLATENUM.state) or ((states('sensor.time') >= states('input_datetime.wed_start_date_LOCKNAME_TEMPLATENUM')[0:5]) and (states('sensor.time') <= states('input_datetime.wed_end_date_LOCKNAME_TEMPLATENUM')[0:5]))) }}"

    thu_LOCKNAME_TEMPLATENUM:
      entity_id:
        - sensor.time
        - input_datetime.thu_start_date_LOCKNAME_TEMPLATENUM
        - input_datetime.thu_end_date_LOCKNAME_TEMPLATENUM
      value_template: "{{ ((is_state('input_boolean.thu_LOCKNAME_TEMPLATENUM', 'on'))) and (strptime(states('sensor.date'), '%Y-%m-%d').strftime('%A') == 'Thursday') and ((states.input_datetime.thu_start_date_LOCKNAME_TEMPLATENUM.state  == states.input_datetime.thu_end_date_LOCKNAME_TEMPLATENUM.state) or ((states('sensor.time') >= states('input_datetime.thu_start_date_LOCKNAME_TEMPLATENUM')[0:5]) and (states('sensor.time') <= states('input_datetime.thu_end_date_LOCKNAME_TEMPLATENUM')[0:5]))) }}"

    fri_LOCKNAME_TEMPLATENUM:
      entity_id:
        - sensor.time
        - input_datetime.fri_start_date_LOCKNAME_TEMPLATENUM
        - input_datetime.fri_end_date_LOCKNAME_TEMPLATENUM
      value_template: "{{ ((is_state('input_boolean.fri_LOCKNAME_TEMPLATENUM', 'on'))) and (strptime(states('sensor.date'), '%Y-%m-%d').strftime('%A') == 'Friday') and ((states.input_datetime.fri_start_date_LOCKNAME_TEMPLATENUM.state  == states.input_datetime.fri_end_date_LOCKNAME_TEMPLATENUM.state) or ((states('sensor.time') >= states('input_datetime.fri_start_date_LOCKNAME_TEMPLATENUM')[0:5]) and (states('sensor.time') <= states('input_datetime.fri_end_date_LOCKNAME_TEMPLATENUM')[0:5]))) }}"

    sat_LOCKNAME_TEMPLATENUM:
      entity_id:
        - sensor.time
        - input_datetime.sat_start_date_LOCKNAME_TEMPLATENUM
        - input_datetime.sat_end_date_LOCKNAME_TEMPLATENUM
      value_template: "{{ ((is_state('input_boolean.sat_LOCKNAME_TEMPLATENUM', 'on'))) and (strptime(states('sensor.date'), '%Y-%m-%d').strftime('%A') == 'Saturday') and ((states.input_datetime.sat_start_date_LOCKNAME_TEMPLATENUM.state  == states.input_datetime.sat_end_date_LOCKNAME_TEMPLATENUM.state) or ((states('sensor.time') >= states('input_datetime.sat_start_date_LOCKNAME_TEMPLATENUM')[0:5]) and (states('sensor.time') <= states('input_datetime.sat_end_date_LOCKNAME_TEMPLATENUM')[0:5]))) }}"


    smtwtfs_LOCKNAME_TEMPLATENUM:
      friendly_name: "Status"
      value_template: >-
         {{
            is_state('binary_sensor.sun_LOCKNAME_TEMPLATENUM', 'on')  or  
            is_state('binary_sensor.mon_LOCKNAME_TEMPLATENUM', 'on')  or  
            is_state('binary_sensor.tue_LOCKNAME_TEMPLATENUM', 'on')  or  
            is_state('binary_sensor.wed_LOCKNAME_TEMPLATENUM', 'on')  or  
            is_state('binary_sensor.thu_LOCKNAME_TEMPLATENUM', 'on')  or  
            is_state('binary_sensor.fri_LOCKNAME_TEMPLATENUM', 'on')  or  
            is_state('binary_sensor.sat_LOCKNAME_TEMPLATENUM', 'on')   
         }}

    
    access_count_LOCKNAME_TEMPLATENUM:
      friendly_name: "Access Count"
      value_template: >-
         {{
            (is_state('input_boolean.accesslimit_LOCKNAME_TEMPLATENUM', 'off'))  or  
            (states.input_number.accesscount_LOCKNAME_TEMPLATENUM.state | int > 0)
         }}


    active_LOCKNAME_TEMPLATENUM:
      friendly_name: "Status"
      value_template: >-
         {{
            is_state('binary_sensor.enabled_LOCKNAME_TEMPLATENUM', 'on')  and  
            is_state('binary_sensor.access_count_LOCKNAME_TEMPLATENUM', 'on')  and  
            is_state('binary_sensor.daterange_LOCKNAME_TEMPLATENUM', 'on') and
            is_state('binary_sensor.smtwtfs_LOCKNAME_TEMPLATENUM', 'on')  
         }}
      device_class: connectivity


###################  sensor:  ####################  


For those who are having problems running setup.sh it looks like you need to be using gawk (tested with 4.2.1, may work with older) but mawk from Ubuntu and nawk in FreeBSD certainly don’t work without some modification of the code.
It does run under Ubuntu if you install gawk and it works in FreeBSD if you install gawk and gsed and patch the code to run those versions.

1 Like

Unfortunately I have no clue what any of that means. I am running home assistant in a virtual box on my windows pc. Any suggestions on how I go about running this?

Are you running Windows 10? You have a couple options, you could install Ubuntu in another VM and install gawk (sudo apt install gawk) or possibly use the WSL (Windows Subsystem for Linux) and do the same thing. Other than that I don’t have anything just yet.
There could probably be a way to patch the code to know that it is using a different awk (busybox for example in what was hassio) but I haven’t had the time to look into it yet as I just stumbled on this myself and tried to get it working.

1 Like

I appreciate the help on this. I may attempt the option you suggest if I have time down the line.

Do you have an alternate method of managing locks and users you can suggest for me? I cannot seem to find anything that works for me. currently I can only lock and unlock my system and I have yet to figure out how I can add users and pins, etc. I was hoping this would be my solution. I will likely connect it back to my SmartThings Hub for now and go that route until I find a better option. If you cannot tell I am new to Home Assistant (within the past month).

^this is the answer

@FutureTense - Great work bro. Quick question, can you maybe get the Status Report Sensor to use the input_text.<your_value__name_1, name_2, etc when updating. That way we’d get the name of the code that was used. And maybe same with the notification delivery…so I know which kid just passed through the frontdoor. Cheers!

1 Like

Ok…So I also have no idea what gawk is…can it be used with a HassIO install?

HassIO (Home Assistant) uses alpine linux as a base. Give the command apk add awk or apk add gawk a try from a shell.

2 Likes

dude that worked! At least it installed, haven’t fiddled yet, but adding gawk as you just said (apk add gawk) through the terminal and then running ./setup worked! I will report back if I end up being wrong cause I cannot fiddle with it until later.

Hi All,

Can someone please tell me if the following looks correct from my config yaml:

# LOCK MANAGER CONFIGS
binary_sensor:
  - platform: template
    sensors:
      allow_automation:
        friendly_name: "Allow Automation"
        value_template: "{{ is_state('input_boolean.allow_automation_execution', 'on') }}"
      system_ready:
        friendly_name: "System ready"
        value_template: "{{ is_state('input_boolean.system_ready', 'on') }}"
        device_class: moving
        
input_boolean:
  allow_automation_execution:
    name: 'Allow Automation'
    initial: off
  system_ready:
    name: 'System Ready'
    initial: off

Seems to be something off here.

code looks ok to me.

Wondering if someone can help me here…

I am getting several errors in my logs in relation to adding/updating/clearing user codes.

“Error while executing automation automation.outsidegaragedoor_clear_code. Invalid data for call_service at pos 1: expected int for dictionary value @ data[‘code_slot’]”

Error while executing automation automation.outsidegaragedoor_add_code. Invalid data for call_service at pos 1: expected int for dictionary value @ data[‘code_slot’]

am i missing something?

code for adding was set by setup.sh:

    - alias: OutsideGarageDoor Add Code
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on' 
      trigger:
        entity_id: binary_sensor.active_outsidegaragedoor_1, binary_sensor.active_outsidegaragedoor_2, binary_sensor.active_outsidegaragedoor_3, binary_sensor.active_outsidegaragedoor_4, binary_sensor.active_outsidegaragedoor_5, binary_sensor.active_outsidegaragedoor_6
        platform: state
        to: 'on'
      action:
        - service: lock.set_usercode
          data_template:
            node_id: >- 
                {{states.lock.schlage_be469nxcen_touchscreen_deadbolt_locked_outsidegaragedoor.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 = 'outsidegaragedoor_pin_' + code_slot | string %}
                {% set code = states['input_text'][codetext].state %}
                {{ code | string }}
    - alias: OutsideGarageDoor Update Code
      trigger:
        entity_id: input_text.outsidegaragedoor_pin_1, input_text.outsidegaragedoor_pin_2, input_text.outsidegaragedoor_pin_3, input_text.outsidegaragedoor_pin_4, input_text.outsidegaragedoor_pin_5, input_text.outsidegaragedoor_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_outsidegaragedoor_' + code_slot | string %}
            {{ is_state(b, 'on') and (trigger.from_state.state != trigger.to_state.state)}}
      action:
        - service: persistent_notification.create
          data_template:
            title: "outsidegaragedoor 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_outsidegaragedoor_' + code_slot | string }}