Syncing Door Lock Pin codes from Web server on the fly

Hello,
We would like to build an application which will let us generate a 4-digit pin code that can be synced automatically to our Schlage Z-Wave lock using a Vera Luup plug-in. I’m wondering if this type of capability would be possible? Currently you can update pin codes on the MyVera site which then syncs to the lock, however we need a way to do it seemlessly from our website (e.g., auto-generate 4-digit pin code, sync automatically through luup plug-in).

Does anybody know if this is possible? Also are there any luup plug-in developers out there that can help us to develop this functionality? If so please let me know.

Thanks!
-Daniel

It’s possible. There are basically two approaches:

a) A Push, from your Web Application, through FindVera (or it’s UI4 equivalent)
Basically all “remote” enabled Vera’s (ones that can be accessed with FindVera) can have “calls” done against them. There are specific “calls” that can be made to do things like Set Lights on, or even change Lock codes. This is how the “remote control” interface (iVera, SQRemote, etc) work, it’s also how the remote HTML UI to Vera itself works.

Unfortunately these protocols aren’t really documented anywhere, but they are relatively simple to replicate.

If you have an in-house App Developer writing you the thing to “generate” PIN’s etc, then they should be able to work out most of the protocol using Firefox/Firebug and “looking” at the interaction that a Web Browser sets off when you initiate the “Set PIN Code” stuff in the Dialog for the lock.

This interaction is different between Findvera.com (UI2/UI3) and it’s UI4 counterpart.

b) A Pull, from a Plugin installed into Vera
This is somewhat like the above, but instead someone writes you a short plugin that you need to install into each and every Vera you want to control, and your App Developer will need to expose something, from your booking website, that each Vera can [securely] call back into in order to “get the next code” (or whatever).

It then just needs to execute the equivalent of the following (extremely rough, never tried) bit of code:

-- wake up and get the pin from some remote service ... -- local args = {} args["UserCodeName"]="RentMe" args["newPin"]=[i]yourNewPIN[/i] local resultcode,resultstring = luup.call_action("urn:micasaverde-com:serviceId:DoorLock1","SetPIN", args, [i]yourDeviceId[/i])

see [tt]S_DoorLock1.xml[/tt] for a complete list of PIN Code setting API’s.

You may want to reach out to @javier to get more detailed version of this… and to have them more formally document the HTTP-protocol used to talk to findvera.com (for UI2/UI3) or cp.mios.com (for UI4)… if you go that route.

there’s no need to use any ‘undocumented’ protocol. the HTTP request that fires the ‘SetPin’ action would look like this:

[url=http://ipaddress:49451/data_request?id=lu_action&output_format=xml&DeviceNum=6&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetPin&UserCodeName=xxxxx&newPin=yyyy]http://ipaddress:49451/data_request?id=lu_action&output_format=xml&DeviceNum=6&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetPin&UserCodeName=xxxxx&newPin=yyyy[/url]

where ‘ipaddress’ is the IP of your vera, and ‘xxxx’ and ‘yyyy’ are
the parameters to the ‘SetPin’ action.

to avoid using ‘extra’ ports and keep everything on port 80, you can use the included redirections:

[url=http://ipaddress/port_49451/data_request?id=lu_action&output_format=xml&DeviceNum=6&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetPin&UserCodeName=xxxxx&newPin=yyyy]http://ipaddress/port_49451/data_request?id=lu_action&output_format=xml&DeviceNum=6&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetPin&UserCodeName=xxxxx&newPin=yyyy[/url]

the only complication beyond this would be if the originating system is ‘outside’ a NAT’ed LAN. in this case, it would be necessary to take advantage of the remote access tunnels.

in short, our servers mirrors HTTP requests on a given TCP port number to a given Vera. to find out which port corresponds to the one you want, you should first login to the findvera service (or cp.mios.com, on recent versions). the specific method depends a lot on details of what’s the desired architecture.

@Javier,
I read their description like they want to build a reservation system, running on their Website, and “calling” one-or-more Vera’s to establish PIN codes (remotely).

however we need a way to do it seemlessly from our website (e.g., auto-generate 4-digit pin code, sync automatically through luup plug-in).

If this is the case, and they want to the “Push” model I described, they’ll need documentation on the details to “talk” to a Vera through/via the findvera.com (UI2/3), or cp.mios.com (UI4) service.

Come to think of it, even I’d love to know where that’s doco’d :wink:

If their Website is on the same Network as Vera, then it’ll be like you describe.

If they use a “Pull” model, then they wont use the URL at all, since they can use the Luup API’s directly, but the Plugin would need to be pre-installed on any Vera they deploy.

I too am trying to get some good documentation on how to work with the door locks and other modules. I had sent an email out trying to get some better info but i haven’t heard anything yet. Actually i think Javier was on the email. About the only way i’ve been able to get thing working properly with some modules in UI2 is going through all the javascript in the website to reverse engineer the calls. It would be nice to have plain english documentation on how to interact completely with every module. I for one don’t own every module so some of this i’m coding blind. I’m told they have a vera setup with some of these modules that can be used for testing, but i haven’t been able to get access to it. I’d like to wrap up my UI2 code so i can move on to UI4 for my windows phone 7 app. Thanks.

Spencer :slight_smile: