Lockitron Community

Lockitron-PHP to respond to Webhooks (used for auto door lock)


I just released on Github the PHP code I used on my Raspberry Pi (and now a remotely hosted website) to respond to Lockitron API Webhooks and issue commands to my Lockitron (in this case to lock the Lockitron 105 seconds after it unlocks).

It’s real basic but lays the groundwork to do more. Feel free Fork it or issue Pull requests or ask me questions.

I’m using this PHP class as well as a MySQL server to register iOS devices for push notifications, notify apps about information received from webhooks, and issue commands to Lockitrons that can’t be issued directly from the iPhone (ex. a delayed lock command).

P.S. If anyone wants to help me develop this Lockitron iPhone app I’m working on feel free to PM me. I love to write code but hate coming up with feature ideas or spending time on the UI.

Has anyone gotten Sense to work?

@Hanlon very cool.

Question - do you get the webhooks you need to actually trigger the state change? This might be changing as the crowdfunded locks immediately reporting a state change even though they are pending is not ideal.

If we do change that, then we’ll looking into also adding pending webhooks so that you see when a request is waiting.


@cameron Yes. The webhooks are extremely timely (sent within a second of the Lockitron actually unlocking) and are reliable (they consistently send every time the lock changes state and only when it physically moves).

As a developer I trust the webhooks much more than the response from the PUT requests to change a lock’s attribute (ex lock/unlock the lock or change the handedness or name of a Lockitron). Sometimes I get a response immediately on the PUT request and other times it times out (even when the lock is awake or waking up). In the case of the Pebble app it leaves the user wondering if the command went through (waiting on the timeout). In the case of the iPhone app I can send a push notification to the user’s device on receiving a webhook confirming that the command did in fact go through. If the user hasn’t approved push notifications then I’m left with constantly getting the lock’s status and checking if anything has changed.


@Hanlon okay, I’ll let you know if this Webhook behavior changes. We might just keep it the way it is for the crowdfunded Lockitrons, but it isn’t ideal.

Have you tried the no-block param set to true on the PUT request?


I’m not sure if I know what you mean but I perform the PUT request asynchronously off of the main thread on both the Pebble and the iPhone so as to not hold up the UI.

PM me if you want to elaborate further but I think we’re on the same page.


The noblock parameter hasn’t been documented yet to my knowledge, but it’s what’s mentioned here:

The idea is that you get a response back showing the activity is pending instead of waiting for it to happen, which is where it will time out, as the lock might not always be online.

If I read it correctly too, it also allows other requests to go through, instead of putting the lock in a holding pattern waiting for your first command to go through.


@anthonylavado @Hanlon thanks for catching this - sorry for the confusion. I will get this added to the API docs.