Lutron Caseta Bridge Pro Custom Component Install

Hey everyone, I just finished a Home Assistant install (0.83.2) in virtualenv on a FreeNAS 11.2 jail yesterday, so far so good. Still very new to all of this.

I got stuck on trying to configure a Lutron Caseta Pro hub/bridge, following the upsert custom component method. After dumping the files into the custom_components directory alongside my configuration.yaml and attempting to restart HA via the GUI, here’s what the log reports:

Log Details (ERROR)
Mon Dec 03 2018 22:08:36 GMT-0600 (CST)
Error executing service <ServiceCall homeassistant.restart (c:df17676cd5964032a6e4095b5ba1180e)>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1177, in _event_to_service_call
await service_handler.func(service_call)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/__init__.py", line 129, in async_handle_core_service
errors = await conf_util.async_check_ha_config_file(hass)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/config.py", line 796, in async_check_ha_config_file
check_ha_config_file, hass)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 340, in check_ha_config_file
component = loader.get_component(hass, domain)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/loader.py", line 92, in get_component
module = importlib.import_module(path)
  File "/srv/homeassistant/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/hass/homeassistant/custom_components/lutron_caseta_pro.py", line 24, in <module>
from . import casetify
  File "/home/hass/homeassistant/custom_components/casetify.py", line 98, in <module>
class Casetify:
  File "/home/hass/homeassistant/custom_components/casetify.py", line 101, in Casetify
loop = asyncio.get_event_loop()
  File "/usr/local/lib/python3.6/asyncio/events.py", line 694, in get_event_loop
return get_event_loop_policy().get_event_loop()
  File "/usr/local/lib/python3.6/asyncio/events.py", line 602, in get_event_loop
% threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'SyncWorker_62'.

I doubled checked my config, IP and mac address check out:

## Lutron Caseta Pro
lutron_caseta_pro:
    bridges:
      - host: 10.0.1.30
        mac: !secret mac_address

“Telnet Support” in the app is enabled. I have a duckdns hostname set up with SSL and port forwarding, all working as expected as far as I can tell. I looked at other faqs and posts, thankfully didn’t see any call for port forwarding or anything to the bridge.

Any ideas what I might be missing? Thanks in advance!

Bump. Anyone have any ideas? Still can’t seem to get this custom component installed. I’d be super grateful for any help.

I narrowed this down to an issue with “asyncio” and it not cooperating with multithreading? I overcame this by changing line 101 in casetify.py from:

loop = asyncio.get_event_loop()

to

loop = asyncio.new_event_loop()

I don’t know enough about this configuration to foresee whether or not this will create issues down the road, but it finally got me to the Lutron configurator on HASS.

Thanks for posting this!
I just ran through adding a Caseta Pro and had the exact same issue. This fixed mine as well.
See comments below for further details.

okay, I’m still have issues. The lights showed up on the front end but I can’t control them with this error showing:

Log output:
2019-01-15 23:06:43 ERROR (MainThread) [homeassistant.components.scene] Error while setting up platform lutron_caseta_pro
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/config/custom_components/scene/lutron_caseta_pro.py”, line 67, in async_setup_platform
yield from bridge.open()
File “/config/custom_components/lutron_caseta_pro.py”, line 296, in open
yield from self._casetify.open(self._host)
File “/config/custom_components/casetify.py”, line 163, in open
loop=Casetify.loop)
File “/usr/local/lib/python3.6/asyncio/streams.py”, line 81, in open_connection
lambda: protocol, host, port, **kwds)
File “uvloop/loop.pyx”, line 1869, in create_connection
File “uvloop/loop.pyx”, line 1858, in uvloop.loop.Loop.create_connection
RuntimeError: Task cb=[shield…_done_callback() at /usr/local/lib/python3.6/asyncio/tasks.py:688]> got Future attached to a different loop

for some reason HA can’t connect to the hub

@ThomasPatrick
I ended up solving my problem. It started because a component file was missing. This caused the async issue. But when I found the missing file and fixed it the change to the line 101 in casetify.py caused a new problem that kept HA from connecting to the hub. I changed it back, and now all works as expected