Adding a new code in doorlock

Is it possible to add a new PIN code on a doorlock by lua scripting ?

I would like to dynamically add and remove PIN codes on my doorlock but I don’t know if it is possible (for security aspect) and if so, how to do it (sample code)

Thanks for your help !

Hi @Raynald_Gelinas!

It should be possible using the core Lua module available on our Ezlo API for Lua scripting. Here you can give it a check at all the modules, the syntax, and a short description of what each module does.

Give me some time as I don’t have access to a lock to test right now, but I’ll reply to you as soon as I can with a sample code!

@slapfrost thank you for the fast reply… However, I’m on a VeraPlus controller. I suppose that the core API is not the same for the VeraPlus and the new Ezlo Hubs right ?

Yes, you are right. The API provided is intended to be used with Ezlo Hubs. Considering the fact that you are using a Vera Plus, it might be possible with Luup Lua extensions or forcing a data request to either add or remove a pin code. I’ll send you a PM, if you can possibly enable remote access on your controller and allows us to create/delete pin codes on it, we should be able to come up with a code that can be useful for you. It’d be posted here as well in case it’s useful for anybody else.

@Raynald_Gelinas you can easily remove or add pin codes using the lines described below.

To add a pin code:

os.execute("curl 'localhost/port_3480/data_request?id=action&DeviceNum=DeviceID&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetPin&json=&UserCodeName=PinCodeName&newPin=NewPinCode'")

To remove a pin code:

os.execute("curl 'localhost/port_3480/data_request?id=action&DeviceNum=DeviceID&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=ClearPin&UserCode=PinCodeSlot'")

DeviceID: The ID of the device to add/remove the pin code.
PinCodeName: The name to be given to the new pin code to be added.
NewPinCode: The new pin code to be added.
PinCodeSlot: The slot that the pin code is occupying on the lock. You can check the pin code slot on the interface, where the pin codes are listed.

If you have any questions, let me know!

Thank you for the information.

However, since you have made your remote tests on my controller, all my zigbee devices are now disconnected. I had this issue several times on my VeraPlus and it is very frustrating because the only way I found to correct the situation is to delete all the devices and recreate again.

Do you have an idea why this is appening only on Zigbee and not Zwave and maybe having a better way to correct the situation ?

Hello Raynald,

Customer support will contact you to get more details on the issue you reported. Please re-enable remote access on your controller and allows us to make a further investigation regarding zig bee settings.

Sorry for the inconvenience.

The remote access is now enable

1 Like

@slapfrost Thank you for the information… it’s working perfectly well ! :slight_smile:

1 Like

Thanks to you for letting me know. If you need further help, do not hesitate!

Yes, I would like to add restrictions to the doorlock if it’s possible…

  • From : timestamp
  • To : timestamp
    This will complete all my needs for what I want to program !

@Raynald_Gelinas the lines attached are for adding and removing restrictions to pin codes. These lines allows you to set daily restrictions.

To add a daily restriction:

luup.call_action("urn:micasaverde-com:serviceId:DoorLock1", "SetPinValidityDate", {["UserCode"] = PinCodeID, ["StartDate"] = "YYYY-MM-DD HH:MM:SS", ["StopDate"] = "YYYY-MM-DD HH:MM:SS", ["Replace"] = 1_OR_0}, DeviceID)
  • UserCode is the pin code index that can be checked from the controller’s web UI.
  • StartDate and StopDate must be given in the format provided: “YYYY-MM-DD HH:MM:SS”
  • Replace (1_OR_0) is a boolean property that will need to be changed if replacing an existent pin code index is required or not.

To remove a daily restriction:

luup.call_action("urn:micasaverde-com:serviceId:DoorLock1", "ClearPinValidity", {["UserCode"] = PinCodeSlot, ["slotID"] = RestrictionSlot}, DeviceID)
  • UserCode is the PIN code slot number. The starting slot number is 1.
  • slotID is the restriction slot number. The starting slot number is 1.

You can find more information about luup variables actions here.

Let me know if you have any questions about it.

2 Likes

@slapfrost Thank you again… I will test it very soon

@slapfrost It’s working well… Thank you again for the information and the your fast & efficient support ! :wink:

3 Likes

Thanks to you! If you need further help, do not hesitate to let us know.