SmartThings and Lockitron


#1

Anybody her can help me make an “SmartApp” with inn the SmartThings?
https://graph.api.smartthings.com/ide/apps

I need to add Lockitron into my SmartThings.


#2

SmartThings doesn’t support direct integration with Lockitron. I haven’t looked at Lockitron’s API yet, but if it’s controllable via HTTP PUT/POST/GET, you can definitely do something yourself since that’s fairly easy to do with the Groovy language SmartApps use. If not, you may have to come up with some sort of creative workaround, perhaps using something like a text or e-mail and IFTTT.

Sorry I can’t be of more help, but I haven’t looked at Lockitron’s API yet, and I think that will be the biggest factor right now until SmartThings possibly decides to support it directly. That being said, if it’s possible to develop a full UI for SmartApps beyond their configuration screens, I haven’t figured out how yet, so I think you’ll be pretty limited there anyway unless I’m missing something here (or if you have a device you want it to integrate with, e.g, a presence sensor–because SmartApps are great at responding to events fired from devices).


#3

http://api.lockitron.com

It is getting updated soon though. They said there’s a v2 coming out.


#4

Oki, thanx.

I know it can be very easy if you know tha basics (i don’t :frowning: )

I also found this, when i was trying to set up http request from my Pebble, but to difficult for me.

Se this link https://github.com/beaulebens/Pebblock/blob/master/pebblock.php


#5

Bump - any action on integrating Lockitron with SmartThings at this stage? I have access to the IFTTT channel, but I’m worried that the Lockitron will be too slow to respond using this method. I can provide code samples, etc but could really use a little guidance. Thanks for any help!


#6

Alright, so re-reading this I have an idea as to what has to happen. Also, I’ll stay in this thread because what @RMo wrote still applies.

The Kwikset code probably won’t help much in this case I’m afraid, as that lock talks directly to SmartThings through Z-Wave, so it’s not a matter of adapting it- you’ll have to write new code for this.

Using the Lockitron API, you’ll need to write something for SmartThings that handles three purposes:

  • Check the state of the lock
  • Toggle lock state
  • Alternatively, call a direct Lock/Unlock request

I don’t use SmartThings at all, but to do the above, you’re going to want to read up on using HTTP Methods with SmartThings. I also don’t know how to add this as an item/object in SmartThings so you would have a button or similar to carry out the task.

To check the status of the lock, Retrieve A Lock is going to be the part you’ll use. You’ll be able to use an HTTP GET to find out the current information about the Lock, and it’s filtered down by your Lock ID (find that here in Retrieve All Locks). When your SmartApp calls for the status of the Lock, you’ll need to have it filter out and store the information under:
"state": "unlock",
In this case here, the lock is unlocked, so you can have SmartThings can show you that it’s open.

After the state check is complete, you can set a Toggle using Locking/Unlocking in the API. You can use an HTTP PUT to have your Lockitron either Lock/Unlock/Toggle. Toggle will obviously put the lock into the opposite of whatever state it’s in, so this will be best for general usage.

To recap, you’ll HTTP GET the state of the lock, and HTTP PUT a command to toggle it.

The third item in the list is purely optional, you can use the same HTTP PUT to lock the unit. This could be useful in a “Leaving Home” or “Going to sleep” type of scene/function, or whatever SmartThings calls it.


#7

To make this work with SmartThings, I think you’ll need to create a SmartThings Device Type, not a Smart App per se (though you can then use any app that supports this device type, which should be the same as other locks that support the SmartThings action “Lock”). I’m currently trying to work on this but don’t have a lot of free time, and I’m either having problems understanding the SmartThings Groovy syntax or the Lockitron API, because if I try something like this, it doesn’t work:

String putBody = '{“state”: “unlock”}'
def httpAddr = "https://api.lockitron.com/v2/locks/id-here"
httpPut(httpAddr, putBody, {})

Specifically, I get a groovyx.net.http.HttpResponseException: Internal Server Error. I don’t know Groovy very well (in the sense that I have only used it for SmartApps, one I wrote for Philips Hue before SmartThings started semi-supporting them), so this could easily be a problem with me, but I’m not sure if it’s a problem with my interpretation of SmartThings/Groovy, or if it’s with my interpretation of Lockitron’s API. If it’s me misunderstanding Lockitron’s API, I could see the “address” I need being something more like “https://api.lockitron.com/v2/locks/id-here?state=unlock”, but that doesn’t seem to work either.

If anyone sees any obvious mistake I’m making here with the API, I’d appreciate knowing (not sure if this is the right forum or not), but this could also easily be a problem with me and SmartThings, athough I’ve successfully used both POST and PUT with Philips Hue in Groovy with similar syntax before.


#8

@RMo
I think this part is where the Lockitron API page is a little unclear in it’s documentation.

Based off the example request they provide, the HTTP Put should be formatted like this:

https://api.lockitron.com/v2/locks/Lock_ID_Here?access_token=Put_Token_Here&state=toggle

As far as API questions go for Lockitron, this is definitely the right place. The Lockitron team will respond as they can with answers about their API, but obviously they won’t know as much about other systems.


#9

Looking at the API capabilities, as best I can tell, there does not appear to be a way to use the API to control the Lockitron via Bluetooth. It is all done via HTTP requests, which means that any attempt to lock/unlock the Lockitron via API will not happen instantly (the default delay would be up to 30 mins).

It seems to me that Lockitron should expose a way for “always on” devices which have a BLE chipset (like a hub/gateway, or even a PC) to send a lock/unlock command to it via Bluetooth which could be handled instanltly (without draining the battery by increasing the WiFi checkin interval).

Does anyone know if Lockitron has plans to expose a Bluetooth Lock/Unlock function via API?


#10

I think this is must as well jlaw. There are several scenarios where I want to be able to control locks from a central hub.


#11

I believe at some point @cameron said there would be a way to access via Bluetooth, but the priority right now is access via the App to enable Sense/Auto-Locking.

Don’t forget that Lockitron has Webhooks, so when it is unlocked/locked it can send a trigger of sorts to other systems for you too :slight_smile:

At the same time, though the requests are HTTP based right now, if you knock on the door it will wake up and carry out the HTTP request right away.


#12

Anyone interested in direct access via Bluetooth should drop us a line at hello@!


Lockitron iBeacon UDID