Lutron smart bridge connection issues

Core version: core-2021.10.6
Lutron Bridge: L-BDG2-WH

I just recently started setting up automations which include lights controlled by the Lutron Smart Bridge. Since setting up the automations, I have started (inconsistently) getting these three errors (below) related to connection and SSL failures.

I used the UI to add the integration and I can see the cert files in the file editor. Network-wise, the bridge has a static IP and is online. I am able to control everything normally through the Lutron app without error or delay. And restarting HA or the bridge has no effect. Additionally, I am able to control the lights just fine in HA with the developer tools and lovelace UI.

Here are the three errors I get related to this automation.

Logger: pylutron_caseta.smartbridge
Source: /usr/local/lib/python3.9/site-packages/pylutron_caseta/smartbridge.py:446
First occurred: 12:07:20 PM (2 occurrences)
Last logged: 12:10:37 PM

Reconnecting...
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pylutron_caseta/smartbridge.py", line 434, in _monitor_once
    await self._leap.run()
  File "/usr/local/lib/python3.9/site-packages/pylutron_caseta/leap.py", line 78, in run
    received = await self._reader.readline()
  File "/usr/local/lib/python3.9/asyncio/streams.py", line 540, in readline
    line = await self.readuntil(sep)
  File "/usr/local/lib/python3.9/asyncio/streams.py", line 632, in readuntil
    await self._wait_for_data('readuntil')
  File "/usr/local/lib/python3.9/asyncio/streams.py", line 517, in _wait_for_data
    await self._waiter
  File "/usr/local/lib/python3.9/asyncio/sslproto.py", line 528, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "/usr/local/lib/python3.9/asyncio/sslproto.py", line 206, in feed_ssldata
    self._sslobj.unwrap()
  File "/usr/local/lib/python3.9/ssl.py", line 948, in unwrap
    return self._sslobj.shutdown()
ssl.SSLError: [SSL: APPLICATION_DATA_AFTER_CLOSE_NOTIFY] application data after close notify (_ssl.c:2756)

Logger: homeassistant.components.automation.entry_lights
Source: components/lutron_caseta/light.py:67
Integration: Automation (documentation, issues)
First occurred: 12:07:17 PM (4 occurrences)
Last logged: 12:10:34 PM

Entry Lights: Error executing script. Unexpected error for call_service at pos 1:
While executing automation automation.entry_lights
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pylutron_caseta/leap.py", line 71, in request
    return await future
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for
    fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 371, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 571, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1491, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1526, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 658, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 830, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 695, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 462, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/lutron_caseta/light.py", line 75, in async_turn_on
    await self._set_brightness(brightness, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/lutron_caseta/light.py", line 67, in _set_brightness
    await self._smartbridge.set_value(
  File "/usr/local/lib/python3.9/site-packages/pylutron_caseta/smartbridge.py", line 286, in set_value
    await self._request(
  File "/usr/local/lib/python3.9/site-packages/pylutron_caseta/smartbridge.py", line 234, in _request
    response = await asyncio.wait_for(
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

Logger: pylutron_caseta.smartbridge
Source: /usr/local/lib/python3.9/site-packages/pylutron_caseta/smartbridge.py:542
First occurred: 12:06:58 PM (2 occurrences)
Last logged: 12:10:28 PM

ping was not answered. closing connection.

Struggling to find what is going wrong here, any help is appreciated!

I never had any luck with the UI to add the lutron integration. Adding it manually in yaml to the config.yaml file following the instructions linked below has worked for me fine with no errors. This is assuming the certs are all good and are in the right place from running the get lutron cert script - pylutron-caseta/get_lutron_cert.py at 6e5cf2aae61fa16442016314cff9a83aa52a4172 · gurumitts/pylutron-caseta · GitHub

Thank you! Upgraded to the beta and haven’t seen the errors appear yet, but if they reappear I will try the manual configuration.

I’m fairly new to HA but am running into this problem myself. How did you manage to upgrade your script exactly? Been trying to figure out a way of replacing the version I’m using but I just don’t see an easy way to. Also did this problem stay fixed for you? I’m on the VM version and it seems rather locked down as far as adding custom files outside the config dir.

I don’t really have a clue on how to set this up manually. Can you provide some guidance? Specifically about how to generate the certificates?

It was a pain in that you had to download the script and run several python commands. Its been awhile since I did this, but I believe the commands to run are in the top of the script file I linked above.

`python -m venv env`
bash: `source ./env/bin/activate`
powershell: `./env/scripts/activate.ps1`
`pip install pyOpenSSL==19.1.0`
`python get_lutron_cert.py`

I ran them on a Linux machine. This guide might help

Once run it generates the certificates in the directory you ran it. Then you put those certificates in your config directory for homeassistant and add the info to the config.yaml file. At some point the script had me push the button on the caseta bridge so make sure it is nearby or you have someone else who can push it for you.

Thanks. I eventually was able to figure out how to run the Python scripts but I am doing this remotely so I think it halted because I was not on the same network. Will have to try it when I get back to where HASS is installed.