Adding a way to set door codes - Part 1: Write a script

< Previous                                                                                            Next >

Setting door codes is a lot more complex than locking and unlocking.  I will walk through the steps with a lot of detail.

  1. Write a 'script' to set the door code.
  2. Create 'helpers' to make it easy to select the door to use, the code slot, and to enter the door code itself.
  3. Use the 'helpers' in the script.
  4. Create a 'card' that uses the helpers and the script.  This is like the lock card, but uses the helpers to get the door, code slot and door code.

Write a 'script' to set the door code

This may sound a little scary, and techie, but I'll walk you through it.
First - open up the Home Assistant - http://homeassistant.local:8123/, then go to 'Configuration in the sidebar.

Then scroll down to find 'Scripts' , click on this.

I have a few scripts already written, but your page will be blank.  Select "Add Script" 


This will bring up the "New Script" page

Enter the name for the Script (As soon and you put the name in, the 'Entity ID' will change to something very similar to the name you entered)

Change "Action Type" to "Call Service"

Now Select the 'Service' by clicking on the 'Service' beneath the "Action Type"...

and select 'lock.set_usercode'


You now need to scroll down on the page to see the "Service data"

We will 'hardcode' the data for this right now.  Later, we will have a way to enter the data from a more friendly web page, or your mobile device.

I will use similar values to the ones I used in Setting a Code. I am changing the usercode, because I want to test it on the lock, so it needs to change to test it.
  1. node_id: 2
  2. code_slot: 4
  3. usercode: '2112'
Enter this as the "Service Data"

Now select "Save Script", Now select the 'back' arrow from the upper left 
You will now see your new script in the list

Select the that is to the right of your script.  This will take you back to the script edit screen.


Select "execute" to run the script.  If you watch the Z-Wave dongle on the Raspberry Pi, it should light up for a bit.  Now you can try the code on your lock to see it work.  Remember, it sometimes takes a few seconds.

Select the 'back' arrow from the upper left  to get out of the script editor.

Now we will create the 'helpers' so we have a way to tell the script which door (node_id), code slot and usercode to use.



< Previous                                                                                            Next >


Comments

Popular posts from this blog

Home Automation

Getting your house to ask you for help: Setting up Email Notification using GMail

Adding a way to set door codes - Part 2: Create helpers