Difference between revisions of "How to use Dashboard to Manage Lock Codes"
Line 90: | Line 90: | ||
#<big>Press '''Save'''.</big>[[File:Lock Code Dashboard tile in use.png|none|frame]][[File:Lock Code entered from Dashboard.png|none|frame]] | #<big>Press '''Save'''.</big>[[File:Lock Code Dashboard tile in use.png|none|frame]][[File:Lock Code entered from Dashboard.png|none|frame]] | ||
#<big>Entering the slot number and a zero will delete the code at the slot number entered.</big>[[File:Enter slot number and zero to delete lock code.png|none|frame]][[File:Lock code deleted with Dashboard tile.png|none|thumb]] | #<big>Entering the slot number and a zero will delete the code at the slot number entered.</big>[[File:Enter slot number and zero to delete lock code.png|none|frame]][[File:Lock code deleted with Dashboard tile.png|none|thumb]] | ||
− | |||
− | |||
− | |||
− |
Revision as of 09:51, 21 March 2021
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 drivers built-in to Hubitat Elevation define each lock code with 3 values:
- Slot Number, which is the code position in the lock.
- The Lock Code itself, which is your 4 to 6 digit PIN code.
- A name for the code.
Using Hubitat Dashboard, you can create a Dashboard tile to set each of those values for a particular lock.
WARNING! 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 for the lock, but without any feedback to the Dashboard about the status of the lock codes on the lock. For complete control and status of your lock codes, Hubitat Remote Admin service is recommended.
Part 1: Create a Global Variable
- In Rule Machine create a Global Variable.
- 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.
- Press Create, to create a Connector for the Global Variable. This will create a virtual device which will also be named Lock Code.
- Set Connector Type to Variable and press Done.
Part 2: Create a Rule Machine rule
- Create a new Rule Machine rule.
- Name the rule Lock Codes.
- Set the Capability of the Trigger to Variable.
- 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.
- Scroll down within the same rule window and select Create Local Variables.
- 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.
- 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.
- For the next action, choose Conditional Actions for the Action Type, and then select Simple Conditional Action.
- Select Variable for the Action Condition capability.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Select the Action Type Run Custom Action.
- Choose Run Custom Action, and Lock for the capability of the action device.
- Select the Lock to act on and press the Update button.
- Select setCode for the custom command and choose number for the parameter type.
- In the "string value" field, enter %slot% and then press the Tab key to update or tap in the white space of the rule.
- Press the Add another parameter button.
- Choose string for the parameter type, entering %code% in the "string value" field.
- One last time, press the Add another parameter button and choose string for the parameter type, entering %name% in the "string value" field.
- When all three parameters have been entered, press the Done with this action button.
- Select Conditional Actions for the Action Type and the select ELSE.
- Press the Done with this action button.
- Select the Action Type Run Custom Action again, just as you did in Step 37, and again choose Run Custom Action, and Lock for the capability of the action device.
- Select the Lock to act on and press the Update button.
- Select deleteCode for the custom command and choose number for the parameter type.
- In the "string value" field, enter %slot% and then press the Tab key to update or tap in the white space of the rule.
- Press the Done with this action button.
- Select Conditional Actions for the Action Type and the select END-IF.
- Press the Done with this action button.
- Select Set Variables, then Set Variable.
- Select Lock Code for the Variable to Set and the select Set string for the operation.
- In the "String to set Lock Code to" field, enter slot:code:name (don't forget to add colons between each string value.
- Press the Done with this action button, then the Done with actions button, and finally the Done button for the rule.
- The purpose of this last action is to set the displayed name to slot:code:name so the previously entered lock code will not be shown.
Part 3: Create a Dashboard Lock Code Tile
- From the Apps menu, Create A New Dashboard.
- Name the Dashboard, then choose the device Lock Code. This is the virtual device that was automatically created by the Global Variable Connector.
- Add a PIN to the Advanced settings of the Dashboard for security again anyone being able to create or delete lock codes.
- You can further enhance security and prevent unauthorized access to your Dashboard containing the Lock Code tile by utilizing Per User Dashboards. Further details can be found in the Hubitat Dashboard documentation.
- Add a tile to your Dashboard with the template Variable String.
- Tap the Dashboard tile and enter a slot number for the code to reside at, the lock code you want to add, and the name to be associated with the code.
- Press Save.
- Entering the slot number and a zero will delete the code at the slot number entered.