KeyMaster Z-Wave lock manager and scheduler

Correct I have an MQTT server for some additional projects, such as zoneminder object/person detection.

This is the path to your zwave stick, just like the built in integration.

It basically maps it to whatever you’d like to call it. I just called it /dev/zwave

I call it /dev/zwave because it’s shorter than /dev/serial/by-id/....

Correct same key.

Hi
All of you
Can someone help me?
I followed and uploaded the code to service: lock.set_usercode
but on my homeassistant it still says I can’t connect

Hi Future Tense. I am a novice at home assistant and am trying to implement the lock manager project that is posted on gitbub https://github.com/FutureTense/lock-manager and created by “FutureTense” It’s an really lock manager but I am stuck on one part of the implementation that I am sure has simple fix which is mostly based on my lack of knowledge. I need to execute the setup script but don’t know how to do it,
Future Tense instruction are to “Make the setup.sh script executable by typing:
chmod +x setup.sh
Now execute the script by typing:
./setup.sh

Where do I type this as I am running HASS.io on an ubuntu Unix server that has Home assistant installed inside a docker container? I am using Samba to map HASSIO as network folder on my PC. The SSH add-on to HASS.io, does not give me root access to the system itself, so I am stuck inside the home assistant container. Not even sure if this makes a difference but I don’t know where or how to execute the script.

Sorry for the novice question.

You’d have to open the shell and execute the command.

I am attempting to convert the script into an integration to make things easier for everyone. :slight_smile:

Thank you for the quick response. Can you tell me how to open the shell?

Via the SSH addon

I can log into the ubuntu server just fine but it is running hassio and docker. My file: packages/lockmanager/setup.sh is in homeassistant which is installed inside a docker container. So when try to execute the set.sh from the ubuntu shell it cannot find the file. image

You need to be where you placed the files.

So I found the complete path to get to the setup.sh file and ran into a permissions problem. Am I suppose to do something in advance to the setup.sh ini file?

I did not mean the ini file… Here what my path directory looks like.

You likely do not own the files with that username, you’ll need to sudo chmod 755 <filename>

Thank you very much for your help. I was able to run setup.sh but it resulted in many errors. Here’s a screen shot. I have no idea what all this means.

This is what is in the setup,sh file.

#!/bin/bash

Read and parse single section in INI file

Get/Set single INI section

GetINISection() {
local filename="$1"
local section="$2"

array_name=“configuration_${section}”
declare -g -A ${array_name}
eval $(awk -v configuration_array="${array_name}"
-v members="$section"
-F= ‘{
if ($1 ~ /^[/)
section=tolower(gensub(/[(.+)]/,"\1",1,$1))
else if ($1 !~ /^$/ && $1 !~ /^;/) {
gsub(/^[ \t]+|[ \t]+$/, “”, $1);
gsub(/[[]]/, “”, $1);
gsub(/^[ \t]+|[ \t]+$/, “”, $2);
if (section == members) {
if (configuration[section][$1] == “”)
configuration[section][$1]=$2
else
configuration[section][$1]=configuration[section][$1]" “$2}
}
}
END {
for (key in configuration[members])
print configuration_array”["“key”"]="“configuration[members][key]”";"
}’ ${filename}
)
}

section=“lockmanager”
files=(.ini)
for item in ${files[
]}
do
# printf " %s\n" $item

filename=$item

GetINISection "$filename" "$section"

sensorfactoryname=${configuration_lockmanager[sensorfactoryname]}
sensorname=${configuration_lockmanager[sensorname]}
lockname=${configuration_lockmanager[lockname]}
lockfactoryname=${configuration_lockmanager[lockfactoryname]}
garageentityid=${configuration_lockmanager[garageentityid]}
numcodes=${configuration_lockmanager[numcodes]}

ACTUAL_LOCK_NAME=${configuration_lockmanager[lockname]}
lockname=$(echo "$ACTUAL_LOCK_NAME" | awk '{print tolower($0)}')
lockfilename=$(echo "$ACTUAL_LOCK_NAME" | awk '{print tolower($0)}')

if (false)
then
   echo $lockname
   echo $lockfactoryname
   echo $sensorname
   echo $sensorfactoryname
   echo $garageentityid 
   echo $numcodes
   echo $ACTUAL_LOCK_NAME
fi

if test -z "$numcodes" || test -z "$lockname" || test -z "$lockfactoryname" || test -z "$sensorname" || test -z "$sensorfactoryname" || test -z "$garageentityid"
then
      echo "lock_manager.ini is incomplete or does not exist"
fi


activelockheader="binary_sensor.active_LOCKNAME_" #ACTIVELOCKHEADER
activelockheaderENTITIES=

inputlockpinheader="input_text.LOCKNAME_pin_" #INPUTLOCKPINHEADER
inputlockpinheaderENTITIES=

for ((i=1; i<=$numcodes; i++))
do
   activelockheaderENTITIES=$activelockheaderENTITIES$activelockheader$i
   inputlockpinheaderENTITIES=$inputlockpinheaderENTITIES$inputlockpinheader$i
   if [ $i -lt $numcodes ]
   then
      activelockheaderENTITIES=$activelockheaderENTITIES", "
      inputlockpinheaderENTITIES=$inputlockpinheaderENTITIES", "
   fi
done

dlmc=$lockfilename"_lock_manager_common.yaml"

dlmc=$(echo “$dlmc” | awk ‘{print tolower($0)}’)

ll=$lockfilename"_lovelace"

ll=$(echo “$ll” | awk ‘{print tolower($0)}’)

rm lovelace 2> /dev/null
for ((i=1; i<=$numcodes; i++))
do
   dm=$lockfilename"_lock_manager_"$i."yaml"

dm=$(echo “$dm” | awk ‘{print tolower($0)}’)

   cp lock_manager.txt $dm
   cp lovelace.code lovelace.$i
   if [ $i -eq 1 ]
   then
      # first pass, setup lock_manager_common
      cp ./lock_manager_common.txt ./$dlmc
      cat lovelace.head >> $ll

      sed -i s/INPUTLOCKPINHEADER/"$inputlockpinheaderENTITIES"/g $dlmc # INPUTLOCKPINHEADER
      sed -i s/ACTIVELOCKHEADER/"$activelockheaderENTITIES"/g $dlmc # ACTIVELOCKHEADER
      sed -i s/LOCKNAME/$lockname/g $dlmc
      sed -i s/CASE_LOCK_NAME/$ACTUAL_LOCK_NAME/g $dlmc
      sed -i s/LOCKFACTORYNAMEPREFIX/$lockfactoryname/g $dlmc
      sed -i s/SENSORNAME/$sensorname/g $dlmc
      sed -i s/SENSORFACTORYNAMEPREFIX/$sensorfactoryname/g $dlmc
      sed -i s/GARAGEDOORENTITYID/$garageentityid/g $dlmc

      sed -i s/INPUTLOCKPINHEADER/"$inputlockpinheaderENTITIES"/g $ll # INPUTLOCKPINHEADER
      sed -i s/ACTIVELOCKHEADER/"$activelockheaderENTITIES"/g $ll # ACTIVELOCKHEADER
      sed -i s/LOCKNAME/$lockname/g $ll
      #read -p "Press enter to continue"
      sed -i s/CASE_LOCK_NAME/$ACTUAL_LOCK_NAME/g $ll
      sed -i s/LOCKFACTORYNAMEPREFIX/$lockfactoryname/g $ll
      sed -i s/SENSORNAME/$sensorname/g $ll
      sed -i s/SENSORFACTORYNAMEPREFIX/$sensorfactoryname/g $ll
      sed -i s/GARAGEDOORENTITYID/$garageentityid/g $ll

   fi

   sed -i s/TEMPLATENUM/$i/g $dm
   sed -i s/LOCKNAME/$lockname/g $dm
   sed -i s/CASE_LOCK_NAME/$ACTUAL_LOCK_NAME/g $dm
   sed -i s/FACTORYNAMEPREFIX/$factoryname/g $dm

   sed -i s/LOCKNAME/$lockname/g lovelace.$i
   sed -i s/CASE_LOCK_NAME/$ACTUAL_LOCK_NAME/g lovelace.$i
   sed -i s/TEMPLATENUM/$i/g lovelace.$i
   cat lovelace.$i >> $ll
   rm lovelace.$i
done


echo creating $lockfilename
rm -rf $lockfilename
mkdir $lockfilename

mv *.yaml $lockfilename
mv $ll $lockfilename\

done

#exit 0

You need to install awk via sudo apt-get install awk

Thanks again. I installed gawk (started with awk but it directed me to gawk) and then executed the script ./setup.sh after making the script executable with the sudo chmod 755 setup.sh command. It looks like there are still a number of problems as you can see in the attached command line image. I am sorry to bother you. I did not realize this was going to be so hard. image

Try symlinking gawk to awk in your /usr/bin directory.

I really appreciate you taking the time to help me. I tried symlinking (never did this before so if you can you check to see if I did this properly that would be good). After symlinking, i went through the same process and the errors remain.

Out of ideas, seems like gawk is missing functions or something.

Thank you again for trying to help out. I wish I could just download the file/files that are created by the setup.sh and modify them for my lock environment/specifics. I can’t believe it would require too much change. I look forward to your future integration that you mentioned in the beginning.

@FutureTense Here are some screens of what I have so far:

image
image

I think this will help alleviate some of the shell issues :slight_smile: