A question that comes up frequently is how to manage lock codes from a Dashboard. This is actually fairly easy with a Rule Machine rule and a Global Variable Connector.
First, each lock code is defined by 3 values: the slot number (Code position), the code itself (PIN code), and a name (Name) for the code. These can be set from a lock's device page:
What we want is a tile on a Dashboard to set those three values for a particular lock. This will look like this:
The string in the center of that tile 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.
Create a Hub Variable of type string. In our example this is called Lock Code. Also create a Connector for it, which creates a virtual device also named Lock Code. In the Dashboard we include this device, and it is selected for the desired tile. The template for the tile is Variable String.
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: