How to use Dashboard to Manage Lock Codes

From Hubitat Documentation
Jump to: navigation, search
Go to the top of the page

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

  1. In Rule Machine create a Global Variable.
    Step 1-Lock Code with Dashboard.png
  2. 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.
      Step 2-Lock Code with Dashboard.png
  3. Press Create, to create a Connector for the Global Variable. This will create a virtual device which will also be named Lock Code.
    Step 3-Lock Code with Dashboard.png
  4. Set Connector Type to Variable and press Done.
    Step 4-Lock Code with Dashboard.png

Part 2: Create a Rule Machine rule

  1. Create a new Rule Machine rule.
    Step 5-Lock Code with Dashboard.png
  2. Name the rule Lock Codes.
    Step 6-Lock Code with Dashboard.png
  3. Set the Capability of the Trigger to Variable.
    Step 7-Lock Code with Dashboard.png
  4. Set the Variable to Lock Code (This is the Global Variable that was created in Step 1) and set the Comparison to *changed*
  5. Press Done with this Trigger Event, and then press Done with Trigger Events.
    Step 8-Lock Code with Dashboard.png
  6. Scroll down within the same rule window and select Create Local Variables.
    Step 10-Lock Code with Dashboard.png
  7. 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.
      Step 11-Lock Code with Dashboard.png
  8. Create the first action in the rule by choosing Set Variables for the Action Type, and then Set Variable for the Action.
  9. Choose temp for the Variable to Set, and Token for the string operation.
  10. In the String to get token from field, enter %Lock Code%
  11. Enter a : (colon) in the Delimiter field, and 0 in the Index field, then press the Done with this action button.
    Step 13-Lock Code with Dashboard.png
  12. For the next action, choose Conditional Actions for the Action Type, and then select Simple Conditional Action.
    Step 12-Lock Code with Dashboard.png
  13. Select Variable for the Action Condition capability.
    Step 17.1-Lock Code with Dashboard.png
  14. Choose temp for the Variable and = (equals) for the Comparison, then enter slot in the String Value field.
  15. Press the Done with this Condition button.
    Step 19.1-Lock Code with Dashboard.png
  16. Select Repeat Actions, Wait for Action Type of the Simple Conditional Action, and Exit Rule for the Action.
  17. Press the Done with this action button.
    Step 20-Lock Code with Dashboard.png
  18. For the third action, select Set Variables, then Set Variable.
  19. Select slot for the Variable to Set, and choose string for the operation.
  20. Enter %temp% in the "Numeric string" field, and press the Done with this action button.
    Step 22-Lock Code with Dashboard.png
  21. In the fourth action, you will again select Set Variables, then Set Variable.
  22. Select code for the Variable to Set, and choose Token for the string operation.
  23. Enter %Lock Code% in the "String to get token from" field
  24. Type a : (colon) in the Delimiter field, and 1 in the Index field and press the Done with this action button.
    Step 25.1-Lock Code with Dashboard.png
  25. For the fifth action, you will once again select Set Variables, then Set Variable.
  26. Select name for the Variable to Set, and choose Token for the string operation.
  27. Enter %Lock Code% in the "String to get token from" field
  28. Type a : (colon) in the Delimiter field, and 2 in the Index field and press the Done with this action button.
    Step 29-Lock Code with Dashboard.png
  29. In the sixth action, choose Conditional Actions for the Action Type, and then select IF (conditions) THEN
  30. Define the condition and select Variable for the Action Condition capability.
  31. Select code for the Variable and != (not equal to) for the Comparison. Enter 0 in the String Value field.
  32. Press the Done with this Condition button., then press the Done with Conditional Action button.
    Step 33-Lock Code with Dashboard.png
  33. Select the Action Type Run Custom Action.
    Step 37-Lock Code with Dashboard.png
  34. Choose Run Custom Action, and Lock for the capability of the action device.
  35. Select the Lock to act on and press the Update button.
    Step 38-Lock Code with Dashboard.png
  36. Select setCode for the custom command and choose number for the parameter type.
  37. In the "string value" field, enter %slot% and then press the Tab key to update or tap in the white space of the rule.
    Step 40.2-Lock Code with Dashboard.png
  38. Press the Add another parameter button.
    Step 42-Lock Code with Dashboard.png
  39. Choose string for the parameter type, entering %code% in the "string value" field.
  40. One last time, press the Add another parameter button and choose string for the parameter type, entering %name% in the "string value" field.
  41. When all three parameters have been entered, press the Done with this action button.
    Step 45-Lock Code with Dashboard.png
  42. Select Conditional Actions for the Action Type and the select ELSE.
  43. Press the Done with this action button.
    Step 46-Lock Code with Dashboard.png
  44. 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.
  45. Select the Lock to act on and press the Update button.
  46. Select deleteCode for the custom command and choose number for the parameter type.
  47. In the "string value" field, enter %slot% and then press the Tab key to update or tap in the white space of the rule.
  48. Press the Done with this action button.
    Step 50.1-Lock Code with Dashboard.png
  49. Select Conditional Actions for the Action Type and the select END-IF.
  50. Press the Done with this action button.
    Step 53-Lock Code with Dashboard.png
  51. Select Set Variables, then Set Variable.
  52. Select Lock Code for the Variable to Set and the select Set string for the operation.
  53. In the "String to set Lock Code to" field, enter slot:code:name (don't forget to add colons between each string value.
  54. 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

  1. From the Apps menu, Create A New Dashboard.
    Create new Dashboard for Lock Code.png
  2. Name the Dashboard, then choose the device Lock Code. This is the virtual device that was automatically created by the Global Variable Connector.
  3. 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.
      Dashboard setup for Lock Code rule.png
  4. Add a tile to your Dashboard with the template Variable String.
    Add Dashboard tile for Lock Codes.png
  5. 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.
  6. Press Save.
    Lock Code Dashboard tile in use.png
    Lock Code entered from Dashboard.png
  7. Entering the slot number and a zero will delete the code at the slot number entered.
    Enter slot number and zero to delete lock code.png
    Lock code deleted with Dashboard tile.png