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

Sorry about being a beginner here. I was able to finally add my dimmer after a lot of killing the script and redoing the process. Now that I have added the device, I am not able to control it. I click on/off and it does not do anything.

Also - does the script need to be always running for this to work?

edit: I was able to get it to work after restarting the python script. It seems the python script stops listening after doing initial setup.

All good. Not sure what the initial issue was exactly but I am pretty sure I know what is wrong now. When you stop the script it doesn’t fail gracefully and can leave the port busy preventing the connection when you restart it. You need to manually kill the process or possibly multiple processes you have started. Once they are all killed you can start it again and I bet it will work.

And yes the script must remain running for the integration to work. It is the only way for ST to talk to and receive messages from the bridge.

Good good glad to hear it!

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

1.Install XCODE
>downloaded not sure what else needs done

2.Install Homebrew (updated pip to newest version)
>found homebrew installed, no clue on pip

3.Update Python via brew
> lost on this one

4.Install Twisted
>lost on this one

5.Install paramiko
>lost on this one

Create a folder (folder called ??? and where) with the two files LutronPi.py and rsa_key
run python LutronPi.py from that folder (got error mentioned above)
followed @njschwartz recommendation and tell bash to reset the “cached” location to the python executable by typing hash -r python
python LutronPi.py
It Worked!!"

I would love to do this on my OS X Mac mini but I need more step by step info installing all the software

Try following this guide to get the basic setup of Python. From there you can do the rest (Twisted, Paramiko). http://docs.python-guide.org/en/latest/starting/install/osx/

Try that and let me know if you need more assistance.

I can fix electronics but code stuff is something of vuddo magic.
Here is what I have so far. Homebrew installed successfully. Python installed not sure it installed right.

Server-2:~ server$ /usr/bin/ruby -e “$(curl -fsSL http raw.githubusercontent.com/Homebrew/install/master/install)”
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir -p /Library/Caches/Homebrew
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown server /Library/Caches/Homebrew
==> Downloading and installing Homebrew…
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 2), reused 3 (delta 2), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https:github.com/Homebrew/brew

  • 0c82cce…8f82e89 master -> origin/master (forced update)
    HEAD is now at 8f82e89 README: update license name.
    Updated 1 tap (homebrew/core).
    ==> Cleaning up /Library/Caches/Homebrew…
    ==> Migrating /Library/Caches/Homebrew to /Users/server/Library/Caches/Homebrew…
    ==> Deleting /Library/Caches/Homebrew…
    ==> Renamed Formulae
    libmongoclient -> mongo-cxx-driver mongo-c -> mongo-c-driver
    ==> Deleted Formulae
    libbson libmongoc
    ==> Installation successful!

==> Homebrew has enabled anonymous aggregate user behaviour analytics.
Read the analytics documentation (and how to opt-out) here:
httpsgit.io/brew-analytics

==> Next steps:

Server-2:~ server$ brew install python
Warning: Building python from source:
The bottle needs the Apple Command Line Tools to be installed.
You can install them, if desired, with:
xcode-select --install

==> Using the sandbox
==> Downloading httpswww.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
######################################################################## 100.0%
==> Downloading https//bugs.python.org/file30805/issue10910-workaround.txt
######################################################################## 100.0%
==> Patching
==> Applying issue10910-workaround.txt
patching file Include/pyport.h
Hunk #1 succeeded at 713 (offset 14 lines).
Hunk #2 succeeded at 736 (offset 14 lines).
==> ./configure --prefix=/usr/local/Cellar/python/2.7.12_2 --enable-ipv6 --datarootdi
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.12_2
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.12_2/share
==> Downloading https//files.pythonhosted.org/packages/9f/7c/0a33c528164f1b7ff8cf068
######################################################################## 100.0%
==> Downloading https//files.pythonhosted.org/packages/e7/a8/7556133689add8d1a54c0b1
######################################################################## 100.0%
==> Downloading https//files.pythonhosted.org/packages/c9/1d/bd19e691fd4cfe908c76c42
######################################################################## 100.0%
==> /usr/local/Cellar/python/2.7.12_2/bin/python -s setup.py --no-user-cfg install –
==> /usr/local/Cellar/python/2.7.12_2/bin/python -s setup.py --no-user-cfg install –
==> /usr/local/Cellar/python/2.7.12_2/bin/python -s setup.py --no-user-cfg install –
==> Caveats
Pip and setuptools have been installed. To update them
pip install --upgrade pip setuptools

You can install Python packages with
pip install

They will install into the site-package directory
/usr/local/lib/python2.7/site-packages

See: https//github.com/Homebrew/brew/blob/master/docs/Homebrew-and-Python.md

.app bundles were installed.
Run brew linkapps python to symlink these to /Applications.
==> Summary
:beer: /usr/local/Cellar/python/2.7.12_2: 6,289 files, 85.5M, built in 5 minutes 19 seconds

Server-2:~ server$ pip install --upgrade pip setuptools
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 569kB/s
Collecting setuptools
Downloading setuptools-30.0.0-py2.py3-none-any.whl (472kB)
100% |████████████████████████████████| 481kB 1.1MB/s
Installing collected packages: pip, setuptools
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Found existing installation: setuptools 23.1.0
Uninstalling setuptools-23.1.0:
Successfully uninstalled setuptools-23.1.0
Successfully installed pip-9.0.1 setuptools-30.0.0

Server-2:~ server$ brew linkapps python
Linking: /usr/local/opt/python/IDLE.app
Linking: /usr/local/opt/python/Python Launcher.app
Linked 2 apps to /Applications
Server-2:~ server$

So it looks like now you just need to install Twisted and Paramiko and you are set. Try this: ‘pip install paramiko’ (no quotes) and then ‘pip install Twisted’ Assuming those both install correctly then you are all set up and you just need to copy the files and run the script. Give it a shit and let me know.

thank you for the help to get me this far. Twisted and Paramiko installed correctly.

Now how do I

  1. Create a folder (folder called ??? and where)

2.then move the two files LutronPi.py and rsa_key

You can create the folder anywhere you like. You could even just put the two files on your desktop it really doesn’t matter. Once you have them wherever you put them, back in terminal you will go to that folder and then run the python LutronPi.py command to actually run the script

Sweet, got it going with your help.

Now I need to figure out the smart thing hub IP and fix it in the script

If you log on to the IDE and select My Hubs in that long list of stuff is the localIP. That is what you need.

So with this i assume its working. Got the luton app to show up in ST and it found the pi, But i don’t see the switches yet

Server-2:misc server$ python LutronPi.py
Running as client
there is a key
<paramiko.client.SSHClient object at 0x10b4c1950>
<paramiko.client.SSHClient object at 0x10b4c1950>
<paramiko.client.SSHClient object at 0x10b4c1950>
Listening
Unhandled Error
Traceback (most recent call last):
File “/usr/local/lib/python2.7/site-packages/twisted/internet/base.py”, line 420, in fireEvent
DeferredList(beforeResults).addCallback(self._continueFiring)
File “/usr/local/lib/python2.7/site-packages/twisted/internet/defer.py”, line 319, in addCallback
callbackKeywords=kw)
File “/usr/local/lib/python2.7/site-packages/twisted/internet/defer.py”, line 308, in addCallbacks
self._runCallbacks()
File “/usr/local/lib/python2.7/site-packages/twisted/internet/defer.py”, line 651, in _runCallbacks
current.result = callback(current.result, *args, **kw)
— —
File “/usr/local/lib/python2.7/site-packages/twisted/internet/base.py”, line 433, in _continueFiring
callable(*args, **kwargs)
File “LutronPi.py”, line 233, in main
reactor.listenTCP(5000, status_site) # pylint: disable=no-member
File “/usr/local/lib/python2.7/site-packages/twisted/internet/posixbase.py”, line 478, in listenTCP
p.startListening()
File “/usr/local/lib/python2.7/site-packages/twisted/internet/tcp.py”, line 983, in startListening
raise CannotListenError(self.interface, self.port, le)
twisted.internet.error.CannotListenError: Couldn’t listen on any:5000: [Errno 48] Address already in use.

{“CommuniqueType”:“ExceptionResponse”,“Header”:{“MessageBodyType”:“ExceptionDetail”,“StatusCode”:“503 ServiceUnavailable”},“Body
Listening
”:{“Message”:“The max number of clients are connected. You will need to wait until someone disconnects before attempting to conn
Listening
ect again.”}}
Connection closed by foreign host

Listening

I see two errors that are breaking things likely because you had started and killed the script a few times while testing. The one above is because even though the script stopped the process is still running. You need to kill it manually.

The second issue you need to unplug and replug in your smart bridge to clear the connections. That’s why you’re getting the max connections error. Fix both of those things and it’ll likely work from there.

My switches are showing up and working!!!

Thang you for all the help.

Works perfectly. Thanks for the updated code!!

No problem. Glad it’s working. :wink:

No problem. Glad you like!

Amazing work @njschwartz ! I was in the process of “trying to” write something similar using STNP as the middleman but will happily jump aboard this bandwagon instead.

Was wondering if there was anyway to define the IP address of the Raspberry Pie and Lutron Bridge in the Smart App as opposed to using the discovery method? For some reason, auto-discovery rarely works on my network and this appears to be the case in this situation as well.

Hmm… Currently the way it’s setup there isn’t a way. It’s probably doable though. So you tried it and it won’t discover your pi? That’s interesting, I wonder why that is. Are you sure the script is running correctly on the pi? Haven’t seen that issue as of yet. I’ve been trying to think of ways to simplify/streamline it but so far haven’t come up with anything great. Let me think…

I think it has to do with my network… Any time I run anything that tries to auto discover on my network it rarely works.

Actually have the script running on OS X but it appears to be running fine. I shows “Listening” and reports any time a light is turned off or on so it’s at least communicating with my SmartBridge Pro okay.

Have been trying to follow the code a bit to figure out the preferences but I’m not yet familiar with Groovy at all so it’s taking a while to figure things out.

By the way… have you seen this script: http://forum.micasaverde.com/index.php/topic,35577.0.html ? It’s an incredibly well written script for Vera that connects to the Lutron Smart Bridge. Figured it could provide some useful ideas for making different things work in SmartThings as well.

1 Like