Problem using updated Lutron Caseta component (HA version 58.0)

I am trying to revitalize my Lutron Caseta within HA again, which broke due to a firmware upgrade distributed by Lutron a few weeks ago. Here are the instructions copied from the latest HA component description:

To use Lutron Caseta devices in your installation, you must first log in to your Lutron account and generate a certificate that allows Home Assistant to connect to your bridge. This can be accomplished by downloading and executing this script, which will generate three files: caseta.key, caseta.crt, caseta-bridge.crt when you run it. See the instructions at the top of the script for more information.

I really have problems, guess because I have so little understanding how this should work.

  1. _“You must first log in to your Lutron account”: Which account? I have a Lutron app on my Android connecting to Lutron and controlling the Caseta devices. This is a smartphone app only, and according to Lutron customer service there is no way to connect to the Caseta system using a PC or Unix device. Lutron’s website shows that there is a “My Lutron” account, but I don’t have one and according to Lutron customer service this account is used for distributors and resellers and needs Lutron approval. So what should I do?

  2. “This can be accomplished by downloading and executing this script”: I downloaded the script and could not find instructions. However, the script seems to be configured for a very specific style of configuration. Running the script on my pi results in many “not found” errors (not surprising as I am not logged in any Lutron account), but I also think it would not work for my configuration as there are certain paths in the script that I doubt would be valid in my case.

Anyway, as you can see I am totally clueless what to do. Any advice or clarification anyone could provide?

I also can not get this to work, I installed Python on windows. When i run the script i keep getting multiple errors. Right now i am stuck @ this error.

Traceback (most recent call last):
File “C:\get_lutron_cert\get_lutron_cert.py”, line 29, in
from cryptography import x509
ImportError: No module named cryptography

The account you use on the app on your phone. The script does the same authentication that your phone would so it can grab the keys needed.

1 Like

Looks like python is missing the openssl library

They’re at the top of get_lutron_cert.py:

# `python -m venv env`
# bash: `source ./env/bin/activate`
# powershell: `./env/scripts/activate.ps1`
# `pip install cryptography==2.1.3 requests==2.18.4`
# `python get_lutron_cert.py`

# your client key         -> caseta.key
# your client certificate -> caseta.crt
# your bridge certificate -> caseta-bridge.crt

For a pi you’d want to use the bash line to activate the virtual environment, the powershell line is for Windows.

Okay, my account credentials for the Lutron app on my smartphone are “[email protected] / password”.
How or where do I connect to the Lutron app so I can run the script? As far as I know there is no windows or linux client for the Lutron bridge. I also do not see a place in the script to supply my credentials.

I am at a total loss. I just do not understand how I can log in into a Lutron account (other than through the Lutron app on my phone).

Is there somebody out there who can explain what I have to do to “log in”?

I was able to successfully run this on a raspberry pi. I copied the script to my home folder. Then I ran the command:

python3 -m venv lutron-env

Note: at least on my pi, running python, rather than python3 complained that the venv module didn’t exist. Running python3 fixed that.
Note2: I chose to name the resultant virtual environment lutron-env so I could tell the difference between it and other virtual environment projects I run.

After that I ran:
source ./lutron-env/bin/activate
pip install cryptography==2.1.3 requests==2.18.4
python3 get_lutron_cert.py

Then the script asked me to copy a link it generated and paste it into a web browser. What happened at that point is that the lutron site asked me to sign in with my lutron account credentials.

After signing in, it took me to a page that had a message showing indicating ‘the page you were looking for does not exist’. HOWEVER, the script indicated that I should copy THAT link (of the error page), and paste it back to the waiting script.

Once I did that, it asked for the local IP address of the hub. Once I provided the IP, it successfully completed generating the key and two cert files. I placed them in the .homeassistant directory, added the lines to configuration.yaml, restarted and my lutron switches were working again (In fact I even did not have to redo groups, they just worked again).

Hope sharing my experience helps someone get it going. I have no Windows environment on which to test, but my understanding is that if you have home-assistant running, you should have the ability to run the script in the same environment.

4 Likes

I was also able to get this working. I spun up a fresh install of Ubuntu in VM. I ran the Python script with “Python3 get_lutron_cert.py”. I was not able to get it to work just running the script “Python get_lutron_cert.py”.

@gonzotek

I tried following your example, which was going great, until I got to installing cryptography.

I’ts showing the following error, any ideas?

Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-j7vd07be/cryptography
Storing debug log for failure in /home/pi/.pip/pip.log

When I run “python get_lutron_cert.py”

I get the following error:

Traceback (most recent call last):
  File "get_lutron_cert.py", line 25, in <module>
    import requests
ImportError: No module named 'requests'

The second error is probably because the pip install command didn’t complete, so that has to be fixed first. Did the virtual environment activate properly? You would see (lutron-env) at the start of the command line prompt if so, assuming you’re following my example. Can you post the pip.log?

@gonzotek
Below is what I followed, pip.log attached, I changed log extension to be able to upload.
pip.yaml (305.4 KB)

pi@hassbian:~ $ python3 -m venv lutron-env
pi@hassbian:~ $ source ./lutron-env/bin/activate
(lutron-env) pi@hassbian:~ $ pip install cryptography==2.1.3 requests==2.18.4
Downloading/unpacking cryptography==2.1.3
  Downloading cryptography-2.1.3.tar.gz (441kB): 441kB downloaded
  Running setup.py (path:/tmp/pip-build-mudrl9yk/cryptography/setup.py) egg_info for package cryptography
    error in cryptography setup command: Invalid environment marker: python_version < '3'
    Complete output from command python setup.py egg_info:
    error in cryptography setup command: Invalid environment marker: python_version < '3'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-mudrl9yk/cryptography
Storing debug log for failure in /home/pi/.pip/pip.log

pip.log after following instructions from script.
pip2.yaml (305.5 KB)

Just in case it matters, I’m on an up-to-date Raspbian Stretch running the home-assistant virtual environment install, not hassbian. I had also recently done
sudo apt-get update
sudo apt-get upgrade
Googling the error suggests that setuptools might need to be updated? This is a little out of my wheelhouse and I don’t want to recommend anything that could break other things in your install.

I ran, sudo apt-get update, sudo apt-get upgrade, this morning prior to upgrading HASS.

I’ll see what the MOD’s have to say.

Would really love to get my lights working again.

Thanks for the assistance, much appreciated.

Thank you thank you thank you!
I was able to get up an running reading the process you describe. I had the impression I needed to somehow log into the Lutron account and then run the script, until you showed that running the script will prompt to log into the account!

A few remarks for my specific case:

  • I ran the script on my “test-pi” which has Stretch / Python 3 installed.
  • Installing cryptography errorred out until I installed libevent-dev, and also (virtual environment enabled)

pip install cffi

After that cryptography was installed successfully.

Finally running the script

python3 get_lutron_cert.py

did as you described above, prompted to paste a url in a browser, which opened a Lutron log in page, which resulted in an error page, I pasted the url of the error page to the terminal window running the script, supplied the local IP address of my Lutron bridge, and the script generated the 3 files (key and 2 cert) which I copied over to my production Pi running Home Assistant. Updating the configuration.yaml completed the setup, and -voila- Home Assistant can control my Lutron switches and dimmers again!

Thank you so much for your help, I really appreciate that!

You were dead on, I ran “pip3 install --upgrade setuptools” and all went well untill I ran “python get_lutron_cert.py” it gave the following error.

Traceback (most recent call last):
  File "get_lutron_cert.py", line 29, in <module>
    from cryptography import x509
  File "/home/pi/env/lib/python3.4/site-packages/cryptography/x509/__init__.py", line 8, in <module>
    from cryptography.x509.base import (
  File "/home/pi/env/lib/python3.4/site-packages/cryptography/x509/base.py", line 16, in <module>
    from cryptography.x509.extensions import Extension, ExtensionType
  File "/home/pi/env/lib/python3.4/site-packages/cryptography/x509/extensions.py", line 18, in <module>
    from cryptography.hazmat.primitives import constant_time, serialization
  File "/home/pi/env/lib/python3.4/site-packages/cryptography/hazmat/primitives/constant_time.py", line 9, in <module>
    from cryptography.hazmat.bindings._constant_time import lib
ImportError: No module named '_cffi_backend'

Thanks to @gonzotek and @cssbhome

Finally got Caseta working again with @cssbhome additional step.

  1. python3 -m venv env
  2. source ./env/bin/activate
  3. pip install cffi
  4. pip install cryptography==2.1.3 requests==2.18.4
  5. python3 get_lutron_cert.py

After it successfully generated the key and cert files, I moved the key and certs to my .homeassistant directory, adjusted my config, rebooted, and what do know, up and running.

Cheers to all, and happy :turkey: day!

2 Likes

I’m hitting a wall on this. Will this process work on hass.io?

I start getting errors after “pip install cffi”

“Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-joz0j4hd/cffi/”

Not sure, as I’m running on Hassbian.

The cffi install is only required if you get “ImportError: No module named ‘_cffi_backend’” when installing cryptography.

Did you just try following the instructions as the script described?

python -m venv env
source ./env/bin/activate
pip install cryptography==2.1.3 requests==2.18.4
python get_lutron_cert.py

I’m getting the same error. Was sooo close! Actually, just before the error you mentioned, I get this text:

No working compiler found, or bogus compiler options passed to
the compiler from Python's standard "distutils" module.  See
the error messages above.  Likely, the problem is not related
to CFFI but generic to the setup.py of any Python package that
tries to compile C code.  (Hints: on OS/X 10.8, for errors about
-mno-fused-madd see http://stackoverflow.com/questions/22313407/
Otherwise, see https://wiki.python.org/moin/CompLangPython or
the IRC channel #python on irc.freenode.net.)

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-fid2r96r/cffi/

Crazy enough, I had all this working on the temporary lutron fix before this was released in .58. But it seems my files from that time don’t work with the released code for some reason so I’m trying to get this script working again. Appreciate any help available.