Lutron Caseta Control w/ Raspberry Pi

I hate to make another Lutron Caseta post as there are already a million of them, but I am working on something I haven’t seen mentioned yet and am looking for advice/support. I am in the same boat as many others in that I have a Caseta system set up that I really like for its speed and reliability compared to ST. I tried other switches (GE and Leviton) but just didn’t like the result as much. Therefore I have made it my mission to find a way to control and get the status of my Caseta devices from within ST thus allowing for things like if motion turn on a light. I know that can be done already via IFTT, but as others know the lag makes this not that useful.

I am still in the early build stage of this, but what I have achieved thus far is to SSH into my Lutron Smartbridge (I do NOT have the pro version) and send commands to get status, turn devices off or on, and set levels. I have created a small python script running on a raspberry pi that makes the connection as well as creates http endpoints to allow for control from a webbrowser or hopefully soon ST. My next step is to make a device handler to tie it all together. I am not much of a coder so I am kinda hacking this all together but am curious if anyone has any thoughts or suggestions on making it work from here. Thanks!

4 Likes

Ambitious! I really like Lutron as well. Integration is easier with the smartbridge pro, as you have more options. But even so, have you looked at the following:

3 Likes

@JDRoberts Thanks for reminding me of this. I had read it a long time ago but since I am not using RadioRA didn’t dwell on it. Looking at it now, I can probably do something similar to get things talking. Instead of using the thingShield I am using LAN but I think it is the same idea overall. I am pretty confident I can get it working.

So far with my testing everything is instantaneous and anytime a change is made to any light the smartbridge sends it out so status updates are instant as well. Hopefully I can use some of Bruce’s ideas to get the device handler/smartapp portion built. Appreciate it!

2 Likes

I’m following this project closely. I have two Lutron Casetas connected to my Wink ecosystem and would also like the ability to possibly control them from ST as well. With Wink 2 coming and alleged local control for everything, I might leave the Lutrons on Wink but it is nice to have options.

Let me know if you need a tester. :slight_smile:

4 Likes

Thanks Brad. I had considered trying the wink hub hack to get it all working together but decided against that. Honestly with the wink 2 hub coming soon, I may check that out and switch entirely. Who knows.

As far as my project I can tell you that it does work. I have achieved the ability to turn a light on or off via ST basically instantaneously. The issue is I am not much of a programmer so getting it put together in a workable package is the issue. I have been reading lots of other people’s code and have some ideas but am not certain I can make it work myself. I plan to keep working at it but it will likely be pretty slow going. I will keep you updated and will gladly share if I get something decent together. Thanks!

2 Likes

Hey Brad and anyone else that might care, just a quick update. I am almost there! The basic functionality is there and I have shown it can all work. I can get status from the Smart Bridge and send commands from the hub to turn lights on and off. At this point I just need to put it all together and clean a bunch of things up. I also need to figure out how to make my raspberry pi server code easily installable/distributable. I am hoping within the next week I will have something together than others can try out and give some feedback on. I will post soon! Thanks

2 Likes

Thanks Nate. Do you have a list of equipment needed for this? I don’t currently have a Raspberry Pi but have been looking to get a Pi 2 or Pi 3. Anything else needed?

I have the Pi B+ which is an older model and it runs fine. The pi isn’t really getting taxed hard as its just running a small web and ssh server script. In reality you could run this on any computer that has python installed I suppose. I used the raspberry pi for a few reasons. I had it collecting dust so figured I should do something with it. It also uses almost no power compared to my desktop PC, and lastly it runs Linux which already has a python environment ready to go.

You do need the Lutron SmartBridge as well and your devices will need to be paired with it and not the Wink hub for it to work.I have just the regular SmartBrige (non pro version) and it works fine. I assume the Pro version would work too but cannot say for certain. That is it though. I will let you know when it is production ready (or at least testable)!

2 Likes

Good news. I think it is done! I have all my Lutron Caseta devices showing up in ST and can control them and see their state. I can use them in another SmartApp (i.e. if motion turn on a light) and they respond almost instantly. I am super happy with how it has come together. I am sure my code is sloppy and not nearly as efficient as it could/should be but it works.

I can easily share the ST code which consists of 2 device types and a smart app. I am just not 100% certain how to share the python code yet. I am going to try to package it to make it a simple install with all the required dependencies but to be honest I don’t know how yet. If you want to try it out let me know.

2 Likes

Fantastic work. Very keen to test this out too. I have Pro version of the lutron hub so will see if that’s an issue or not.

Re the Raspberry PI, any special needs there as I get that ready. Eg stock versions of Python that come with Debian Jessie??

Also, I assume this is one way control, ie control Lutron devices from ST side of the hosue and not bidirectional control from either side.

Again great work.

1 Like

@zala Thanks. Nothing special regarding the raspberry pi. I am running stock jessie. What do you mean when you say bidirectional control? This works basically the exact same way the hue bulbs work when using a hue hub. I will try to get it packaged up and posted for people to try out soon… Maybe tonight if times allows.

1 Like

Thanks. Was thinking without thinking :):

All my Lutron goodies are boxed up right now as I’ll be moving to a new home soon where I’ll be unleashing smarthome hell on my family. I’m quite done with my existing Frankenstein approach of trying everything to see what works/works best for the new home.

My thoughts re bidirectional were,…would ST devices show up in the SmartBridge Pro hub and be controllable from there. Beautiful little peco controlling a zwave fan module etc.

More I think about that I realize its an ideal that cannot be delivered until both parties allow that.

The exciting concept is using your solution I can at least have nice WaF light switches and still control them from ST.

1 Like

@zala I know where you’re coming from. I just moved into a new house and have decided to try to put things together in a more standardized system. In the past I had all kinds of random switches and was never quite happy with any. I really like my caseta system but no ST integration annoyed me. Amazon echo integration made it a little better but I still wanted it all to work from one place.

While I couldn’t get ST devices ever in the lutron app, your idea about the pico may be doable actually in some form. To be honest I haven’t looked at what the pico sends to the bridge when you press a button. Assuming it sends a specific message I could grab and parse that into a ST response. I can look at that… I’m curious now.

3 Likes

Ah, I forgot about the Lutron Smart Bridge - I don’t have one of those. I’ll keep an eye on eBay and see if I can score a deal on one, but I suspect I’ll have a Wink 2 before that happens. Nevertheless, great job - this will help a ton of users.

I was just planning to do pretty much this exact same thing, making a REST API for Lutron and then driving it with ST. I’m a Python dev by day, so I’d be happy to help build on this.

1 Like

Steve!! I would LOVE your help with this in a number of ways you have no idea. I am not a python dev by any means. I know enough of the language to hack something together as I did here but it is UGLY. lol I am happy to send you the code as long as you don’t make too much fun of me for how bad it is. :smile: It really is hacked together from numerous different places and examples so it may be slightly difficult to follow. I started out trying to use flask but switched to twisted to handle the API calls and it uses Paramiko to handle the SSH portion.

As I mentioned I am using a non pro smartbridge which has some limitations compared to the pro version but for me it does everything I had hoped for really. I am not 100% certain this will work on a pro bridge because I don’t know if the RSA key will work on it like it does on the non pro versions. I will try to get the code on github and then send you the link.

1 Like

Ok~So for Steve and anyone else that wants to take a look at the code I threw it up on github (link below). Again, I know the code is pretty sloppy so I apologize for that. Also, in the LutronPi code you will see that the ip addresses of the smartbridge (line 220) and the ST hub (line 209) are hardcoded in. I am sure there is a better way but that is what I did for now anyway. Lastly, when you run this on the pi the command to start it all is “python LutronPi.py client {Your Pi’s IP Address}”. You will need the packages listed at the top of the file (twisted and paramiko are the main ones I believe). Lastly make sure the RSA key file is in the same directory. Let me know how it goes if anyone actually try’s it out.

LutronPi Github

2 Likes

Thanks for sharing! I’m happy to help out. I’ve had a ST hub for a while now but I’ve only used a couple ZigBee bulbs and my Harmony remote. I wasn’t impressed with Leviton or GE switches and dimmers but I fell in love with the style of the Lutron switches and knew I had to somehow make them work. I just today got started with my Smart Bridge Pro. I have 3 in wall dimmers and I also have a couple plug in dimmers with Pico remotes (another big selling point to Lutron). You won’t get any judgement from me on your code! Getting things working with the Pro Bridge probably won’t be too hard. There are some pretty robust Telnet libraries for Python that can take care of calling out to it. Refactored, the code could easily work with both. I’ll try and take a look at it this weekend.

1 Like

I was the same way. Wanted to go all z-wave but just didn’t love the GE and Leviton switches either. :confused: I really wish Lutro Caseta had a fan controller. Don’t understand why they don’t. With the pro bridge you will have some more options (ramp rate, more info from the pico remotes) from what I understand. The telnet interface uses a different command structure from the ssh that I implemented. It uses the Lutron Interface protocol which has a lot better documentation. Anyway I look forward to hearing what you think and if it works at all for you. Thanks!

2 Likes

Itching to try it! Will just run your Python script on my phone which also runs LANnouncer.