Difference between revisions of "How to use Dashboard to Manage Lock Codes"

From Hubitat Documentation
Jump to: navigation, search
(Replaced content with " <big>'''We're moving!''' Please visit http://docs2.hubitat.com for the latest documentation.</big> <big> This document is available at: http://docs2.hubitat.com/en/how-t...")
(Tag: Replaced)
 
(15 intermediate revisions by one other user not shown)
Line 1: Line 1:
Managing lock codes isn't a difficult task with Lock Code Manager, and Hubitat Remote Admin is easiest way to do this when you're away from home. However, if you're comfortable with creating Rule Machine rules and a Global Variable Connector., it's possible to create and change lock codes with Hubitat Dashboard.
 
  
The lock driver built-in to Hubitat Elevation defines each lock code with 3 values:
+
<big>'''We're moving!''' Please visit http://docs2.hubitat.com for the latest documentation.</big>
  
* Slot Number, which is the code position in the lock.
+
<big>
* The Lock Code itself, which is your 4 to 6 digit PIN code.
+
This document is available at: http://docs2.hubitat.com/en/how-to/use-dashboard-to-manage-lock-codes
* A name for the code.
+
</big>
 
 
Using Hubitat Dashboard, you can create a Dashboard tile to set each of those values for a particular lock.
 
 
 
'''<span style="color: red;;">WARNING!</span>''' While it's possible to set the Slot, Lock Code and Name from the Dashboard with this technique, you will not be able to see what slots are occupied in the lock and by which codes. You will need to know yourself which slots are occupied. This rule will change the code and name you enter in any slot you enter on the lock, but without any feedback to the Dashboard. For the complete control and status of your lock codes, the Hubitat Remote Admin service is recommended.
 
 
 
# In Rule Machine create a Global Variable.[[File:Step 1-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Enter '''Lock Code''' for the global variable Name, set the Variable Type to '''String''', and enter '''2:0''' in the Set initial value field.
 
#* '''NOTE''': Be sure to include a colon between the 2 and 0.[[File:Step 2-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Press '''Create''' to create a Connector for the Global Variable. This will create a virtual device which will also be named '''Lock Code'''.[[File:Step 3-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Set Connector Type to '''Variable''' and press '''Done'''.[[File:Step 4-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Create a new Rule Machine rule.[[File:Step 5-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Name the rule '''Lock Codes'''.[[File:Step 6-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Set the Capability of the Trigger to '''Variable'''.[[File:Step 7-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Set the Variable to '''Lock Code''' (This is the Global Variable that was created in '''Step 1''') and set the Comparison to '''*changed*'''
 
# Press '''Done with this Trigger Event''', and then press '''Done with Trigger Events'''.[[File:Step 8-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Scroll down within the same rule window and select '''Create Local Variables.''' [[File:Step 10-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Set Local Variables with the following '''Name''', '''Type''' and '''Value''' for each.
 
#* '''NOTE:''' For the Local Variable labelled '''name''', the Value field cannot be blank. Press the spacebar once in its '''Value''' field so you will be able to continue. For the Local Variable labelled slot, the type is '''Number''', rather than '''String''' like the other Local Variables in the list.[[File:Step 11-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Create the first action in the rule by choosing '''Set Variables''' for the Action Type, and then '''Set Variable''' for the Action.
 
# Choose '''temp''' for the Variable to Set, and '''Token''' for the string operation.
 
# In the '''String to get token from''' field, enter '''%Lock Code%'''
 
# Enter a ''':''' (colon) in the Delimiter field, and '''0''' in the Index field, then press the '''Done with this action''' button.[[File:Step 13-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# For the next action, choose '''Conditional Actions''' for the Action Type, and then select '''Simple Conditional Action'''.[[File:Step 12-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Select '''Variable''' for the Action Condition capability.[[File:Step 17.1-Lock Code with Dashboard.png|none|thumb|615x615px]]
 
# Choose '''temp''' for the Variable and '''=''' (equals) for the Comparison, then enter '''slot''' in the String Value field.
 
# Press the '''Done with this Condition''' button.[[File:Step 19.1-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Select '''Repeat Actions, Wait''' for Action Type of the Simple Conditional Action, and '''Exit Rule''' for the Action.
 
# Press the '''Done with this action''' button.[[File:Step 20-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# For the third action, select '''Set Variables''', then '''Set Variable'''.
 
# Select '''slot''' for the Variable to Set, and choose '''string''' for the operation.
 
# Enter '''%temp%''' in the "Numeric string" field, and press the '''Done with this action''' button.[[File:Step 22-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# In the fourth action, you will again select '''Set Variables''', then '''Set Variable'''.
 
# Select '''code''' for the Variable to Set, and choose '''Token''' for the string operation.
 
# Enter '''%Lock Code%''' in the "String to get token from" field
 
# Type a ''':''' (colon) in the Delimiter field, and '''1''' in the Index field and press the '''Done with this action''' button.[[File:Step 25.1-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# For the fifth action, you will once again select '''Set Variables''', then '''Set Variable'''.
 
# Select '''name''' for the Variable to Set, and choose '''Token''' for the string operation.
 
# Enter '''%Lock Code%''' in the "String to get token from" field
 
# Type a ''':''' (colon) in the Delimiter field, and '''2''' in the Index field and press the '''Done with this action''' button.[[File:Step 29-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# In the sixth action, choose '''Conditional Actions''' for the Action Type, and then select '''IF (conditions) THEN'''
 
# Define the condition and select '''Variable''' for the Action Condition capability.
 
# Select '''code''' for the Variable and '''!=''' (not equal to) for the Comparison. Enter '''0''' in the String Value field.
 
# Press the '''Done with this Condition''' button., then press the '''Done with Conditional Action''' button.[[File:Step 33-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Select the Action Type '''Run Custom Action'''.[[File:Step 37-Lock Code with Dashboard.png|none|thumb|600x600px]]
 
# Choose '''Run Custom Action''', and Lock for the capability of the action device.
 
#
 
 
 
The string in the center of t'''hat ti'''le can be set, and contains the 3 values. In this case 3 is the slot number, 4567 is the code, and Jason is the name. These 3 values must be in that order and separated by colons, as shown.
 
 
 
Finally, create this rule below. Note that it has 4 local variables defined.
 
 
 
Some notes about this rule: The action after the IF is a Custom Action (setCode) on the lock to set the codes for. The custom action has 3 parameters. The first parameter is a number (%slot%), and the other two are strings (%code% and %name%). The action after the ELSE is also a custom action (deleteCode) on the lock, with one parameter. The parameter is a number (%slot%) . The lock used in this rule is called "My Lock", which is a virtual lock I keep around for stuff like this. At the end of the rule, we set Lock Code to display "slot:code:name:" so as to hide the previously set lock code and show what to do next time.
 
 
 
After the string shown above (3:4567:Jason) was entered into the Dashboard tile, the resulting lock code was created:
 
 
 
To remove a lock code, enter the slot number and 0 separated by a colon, like this: 2:0.
 
 
 
This will erase slot 2, leaving the lock in this state:
 
 
 
One final thought: Perhaps this Dashboard should have a Pin to protect access to it, given that it can create a lock code with which the lock can be unlocked. You can do this in the Dashboard app for this Dashboard under Advanced options:
 

Latest revision as of 04:23, 25 September 2022

We're moving! Please visit http://docs2.hubitat.com for the latest documentation.

This document is available at: http://docs2.hubitat.com/en/how-to/use-dashboard-to-manage-lock-codes