Adding a way to set door codes - Part 4: Use the script in a 'Card'


< Previous
                                                                                           Next>

We have a script that gets information from 'helpers'.  Now we need to give a person a way to provide that information to the 'helpers'.  This is how we will tie this all together.   We make a 'card' that we will put on our dashboard.

  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.

Create a 'card' that uses the helpers and the script.

If you are not already there, open up the Home Assistant - http://homeassistant.local:8123/then go to your 'Door Controls' dashboard in the sidebar.

This should still have the door lock 'Card' on it from the earlier post Creating a dashboard.
Select the from the upper right, and select "Edit Dashboard".

Select, and then select the "Entities" card. This one:

In the following screen

The "Entities Card Configuration" appears.  It has some default values in it we will replace.

First, enter a title - "Set User Lock Code on Door"
The section on the right is a preview of what the final card will look like.  Notice that the name is displayed.
In the "Entities (Required)" section, select the first down arrow next to the top 'Entity'.

 Find your "Lock Name" (input_select.lock_name) helper in the list, and select it.
Notice that the preview updates to show the helper.

In the "Entities (Required)" section, select the down arrow next to the 'Entity' beneath the "input_select.lock_name" (you may need to scroll down to it).

 Find your "Key Code Slot" (input_text.key_code_slot) helper in the list, and select it.

Notice that the preview updates to show the "Key Code Slot" helper beneath the "Lock Name" helper.

In the "Entities (Required)" section, select the down arrow next to the 'Entity' beneath "input_text.key_code_slot" (you may need to scroll down to it).

 Find your "User Code" (input_text.user_code) helper in the list, and select it. 

Notice that the preview updates to show the "User Code" helper.

In the "Entities (Required)" section, select the down arrow next to the 'Entity' beneath "input_text.user_code" (you may need to scroll down to it).  The fourth one looks a little different, but it acts the same way as the others. 


Find your script (script.set_door_lock_code) in the list, and select it. 




Notice that the preview updates to show the "Set Door Lock Code" with a blue 'EXECUTE" next to it.


Now 'SAVE' the Card.

Your Dashboard will now have two cards on it.  The card to lock the specific door, and a card to set the lock code on one of your doors.

Get out of the "EDIT" mode of the dashboard by selecting the X at the upper left. This puts the Dashboard back to what it will look like whenever you use it.

Your "Key Code Slot" and "User Code" may say 'unknown' at this point.  You can just click on the blue editor to the right of them to set the very first value.

Then enter the number and click the X.  You only need to do this the very first time you use them.

It is very important that you only use numbers between 1 and 30 in the "Key Code Slot" and numbers from 1000 to 99999999 in the "User Code" (If you wonder about the codes 0000 - 0999, it is just because we are cutting corners you cannot use these).  The helpers can be changed to make sure that a person puts in the right values, but for right now - lets see this work!

Enter a number between 1 and 30 in the "Key Code Slot".
Enter a number from 1000 to 99999999 in the "User Code".

Click the blue 'Execute'.  Now try the code on the Kwikset Lock.  It should unlock it.

On a Mobile Device

Look at On a Mobile Device for opening up the dashboard on your phone.

The dashboard will now have the card on it:
You can set the code slot and user code (and select the room if you have more than one), and "Execute"!

Now you have a way to change your door codes with your phone, but only if you are on your local network.

Now you have a way to change your door codes, but only if you are on your local network.  If you want to be able to do it from anywhere (the 'internets'), then you either need to go full-bore techie and start learning about port forwarding and how to make sure SSL (say what?!?) is set up right - or you spend $5 a month on Nabu Casa.  

Pretty sure it is worth it, but some like to tinker.  If you decide to set up your own server with forwarding etc, drop me a line, or a comment below.

Pat Yourself on the Back

There is an absolute TON more things you can do with Home Assistant than just set up a door lock.  What I wanted to do here was give a beginner a way to get a foothold and see something work.  You can likely tell from this blog that I am not much of a UI (yep, there it is again) guy.  The 'helpers' we made were intentionally very, very simple.  To do this better, the helpers could make sure that the stuff a person puts in will actually work.  Helpers can make sure something is just numbers, and they can make sure that they are in a certain range, or that they are a certain number of characters.

Take a look around the Home Assistant site.  Don't be afraid to try to make things happen with it.  You might end up telling Alexa to lock your doors, turn the air conditioner on and record your favorite TV show.

Just do me one favor: write about it when it works, and when it doesn't.

I hope this helped, and my humor was not too bad.  Cheers.




< Previous                                                                                           Next>

Comments

Popular posts from this blog

Home Automation

Kwikset 912

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