[BETA] Lutron Caseta Integration using Raspberry Pi (Pro or Standard Bridge) [DEPRECATED--See new Release thread instead]

This project is for those of us who love the reliability and flexibility of the Lutron Caseta devices but also want to control them via SmartThings. Each of your Caseta Devices will show up in ST as a device and can be controlled from ST just like any other device. Manual changes to lights will also update to ST as expected. I have been running this setup for several weeks now without issue. I have the non Pro version of the SmartBridge and am currently uncertain if it will work for those of you with the pro version. This setup is fast and reliable but does take a bit of technical know how to get setup. I hope to make this simpler in the future.

UPDATE: I can now confirm that this does indeed work on both the Pro and non Pro versions of the SmartBridge. I can also confirm it will run on a Raspberry Pi, Windows, Mac, and Linux machine as long as you correctly setup the python enviroment.

UPDATE 2: I have added the rsa_key to the script itself so you no longer need the separate file and can ignore that step below.

Setup

The setup consists of the following steps:

  1. Setup your raspberry pi
  2. Run the python script
  3. Install the device type handlers in the ST IDE
  4. Install the smartapp in the ST IDE
  5. Configure the smartapp on your phone or tablet

1. Setup your raspberry pi

This is likely to be the most challenging step of the install. On your raspberry pi you will need python installed (it typically comes preinstalled) as well as the additional packages Twisted and paramiko. Assuming you have the python package manager installed you can simply type pip install Twisted and pip install paramiko (paramiko has several dependencies which also need to be installed. Pay attention to any errors you might get when trying to install it).

Once these are all installed, create a folder on your pi and place the files LutronPi.py and rsa_key into it. These files are located at my github. Open the LutronPi file in a text editor and find the lines:

Edit these lines with the appropriate IP addresses for your ST hub and your Lutron SmartBridge. I HIGHLY recommend you give your device static IP addresses as IP changes will break everything.

2. Run the python script
If everything is setup correctly typing ‘python LutronPi.py’ should run the script and you will see some output on the screen. Give it a few seconds to make the connections and then adjust a light and you should see additional output. From there just leave it running. If you SSH into your raspberry pi like I do you can run the script using ‘nohup python LutronPi.py &’ This will run it without showing all the output and will also not kill the script when you terminate the ssh connection to your pi. Make sure you test it first the other way though.

3. Install the device type handlers in the ST IDE
Install and publish the two device types from the github into the ST IDE.

4. Install the smartapp in the ST IDE
Install and publish the smartapp from the github into the ST IDE.

5. Configure the smartapp on your phone or tablet
Finally open the ST App > Marketplace > My Apps and find the Lutron Caseta Service Manager. Select it and then wait until it finds your raspberry pi.


Select it and choose next and wait until it finds all of your switches.

Select your switches, hit Done and then Done again. That’s it! At this point all your Caseta device should be available in ST and available to control directly or via other smartapps, CoRE, etc.

I know the install is a bit cumbersome currently, and I hope to improve that as I have time. I just wanted to make this available to those who might be savy enough and interested in trying it. Please provide feedback and let me know if anything isn’t working and I will try to help. Thanks a lot!

9 Likes

Is there a way to run these python scripts on a Windows 10 pc instead?

I haven’t personally tested it but I am pretty certain that if you were to setup a Python environment on your windows 10 machine and run the script it would work just the same. Here a link to setting something like that up: https://www.davidbaumgold.com/tutorials/set-up-python-windows/ If you try it let me know how it goes. I’m happy to assist if I can.

Nate

1 Like

Ok…so it took some work but I got python 2.7 64bit installed…installed twisted and Paramiko and copied the lutronpi.py and rsa_key file to the c:\python27\ folder. I executed python c:\python27\lutronpi.pyramid but I get "error 2 no such file or directory: xrsa_key’ "
Any ideas

Odd~I have two thoughts. I THINK that it may be due to how you got the files. Does the file rsa_key have an extension? Did you download the zip from github or copy and paste it into a file? The file cannot have an extension or it will break it. Can you check that first?

The other thought is the file is rsa_key not xrsa_key. That may have something to do with running it on windows or maybe it is due to accidentally adding an x to the file?

I got this fantastic script working with the help of Njschwartz last night and so far it’s running like a dream. It took a few small changes to get it working with Windows 10 and I can now remove my Harmony Hub workarounds and return my wink hub 2. The response time is excellet.

Huge thank you for taking the time last night to help getting this working.

A few notes to anyone needing to get this working in windows:

  • I tried multiple versions of python. The only one that was able to successfully install the Twisted add on was Python 2.7 64 bit version.
  • I’m not sure if it was necessary but I also installed pypiwin32 (windows installer for 2.7 64bit version) from this location

https://pypi.python.org/pypi/pypiwin32

  • lastly we edited the script to explicitly point to the location of the rsa_key file
1 Like

Really glad you got it all working! I hope to find a way to improve the setup process to be a little less cumbersome but great to know it works for others and on any device not just a raspberry pi. Thanks for trying it out!

1 Like

Hi, I’m trying to run this on a mac os and I’m having this error. Could you point me in the right direction.

Traceback (most recent call last):
File “LutronPi.py”, line 7, in
from twisted.internet import reactor, task
File “/usr/local/lib/python2.7/site-packages/twisted/internet/reactor.py”, line 38, in
from twisted.internet import default
File “/usr/local/lib/python2.7/site-packages/twisted/internet/default.py”, line 16, in
from twisted.python.runtime import platform
File “/usr/local/lib/python2.7/site-packages/twisted/python/init.py”, line 11, in
from .compat import unicode
File “/usr/local/lib/python2.7/site-packages/twisted/python/compat.py”, line 35, in
from io import TextIOBase, IOBase
File “/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py”, line 51, in
import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so

Hey Joe. Glancing at your error there it appears it is failing at line 7 which is one of the imports for twisted. This would make me believe that there is something wrong with your install of Twisted. You did get Twisted installed with no errors?

here is my log for installing twisted
Collecting Twisted
Downloading Twisted-16.5.0.tar.bz2 (3.0MB)
100% |████████████████████████████████| 3.0MB 421kB/s
Collecting zope.interface>=3.6.0 (from Twisted)
Downloading zope.interface-4.3.2-cp27-cp27m-macosx_10_9_x86_64.whl (133kB)
100% |████████████████████████████████| 143kB 4.3MB/s
Collecting constantly>=15.1 (from Twisted)
Downloading constantly-15.1.0-py2.py3-none-any.whl
Collecting incremental>=16.10.1 (from Twisted)
Downloading incremental-16.10.1-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/site-packages (from zope.interface>=3.6.0->Twisted)
Building wheels for collected packages: Twisted
Running setup.py bdist_wheel for Twisted … done
Stored in directory: /Users/****/Library/Caches/pip/wheels/0c/52/38/0066e36ca595009ecd46c4d215b77447f1b200aa2ce7c7da00
Successfully built Twisted
Installing collected packages: zope.interface, constantly, incremental, Twisted
Successfully installed Twisted-16.5.0 constantly-15.1.0 incremental-16.10.1 zope.interface-4.3.2

So yea it appears to be installing fine. My guess (and I could certainly be wrong) from some googling is it has to do with the various ways python can be installed on a Mac. It seems there can be issues if you are using the preinstalled version that comes with OSX. My suggestion would be to try the guide at this link for setting everything up: http://docs.python-guide.org/en/latest/starting/install/osx/

I cannot promise this will work but I think it will get you in the right direction. It may be that you just need to do that first part and install the gcc compiler perhaps. I don’t currently have a Mac to test this all on unfortunately. :confused:

that’s the page I used to get started with this, i’ll try installing python 3 and see how that goes, thanks for your help

Interesting. Look at this: http://stackoverflow.com/questions/34386527/symbol-not-found-pycodecinfo-getincrementaldecoder It may answer your question. Are you running from the command line? Perhaps try the suggestions in the first response there?

1 Like

ok that seems to do something, but this prompt up;

Running as client
there is a key

what do I type in now?

Nothing~it is working! :slight_smile: Just run the smartapp and it should discover your server and then your devices. Please let me know if it works. :slight_smile:

It’s responding, thank you so much for your help. who knew a simple “hash -r python” would fix it.

lol Glad that is all it was. So many little things that can break everything! Please leave feedback/suggestions/bugs if you note any.

To recap my process to get this to run on mac os;

  1. Install XCODE
  2. Install Homebrew (updated pip to newest version)
  3. Update Python via brew
  4. Install Twisted
  5. Install paramiko
  6. Create a folder with the two files LutronPi.py and rsa_key
  7. run python LutronPi.py from that folder (got error mentioned above)
  8. followed @njschwartz recommendation and tell bash to reset the “cached” location to the python executable by typing hash -r python
  9. python LutronPi.py
  10. It Worked!!
1 Like

@Joe_D @stephack Again I am really glad you both got it working. I was wondering if you could both confirm which SmartBridge version you have (regular vs pro)? Another guy with the pro version tried it but didn’t seem to be able to connect. I assume it is the pro bridge needs a different ssh key but cannot be sure. Thanks guys!

Regular Smart Bridge for me.

1 Like