upsert / lutron-caseta-pro

Custom Home Assistant Component for Lutron Caseta Smart Bridge PRO / RA2 Select
Apache License 2.0
184 stars 38 forks source link

Doesn't work in HomeAssistant 0.69 beta #9

Closed cgarwood closed 6 years ago

cgarwood commented 6 years ago

HomeAssistant 0.69 beta includes a PR that changes the way custom_components load: https://github.com/home-assistant/home-assistant/pull/14211

It looks like this breaks the custom component, as I get the following error with 0.69:

File "/home/hass/custom_components/lutron_caseta_pro.py", line 24, in <module>
    from . import casetify
SystemError: Parent module '' not loaded, cannot perform relative import
upsert commented 6 years ago

I was able to fix the import problem by squeezing all the code into one file, but after that all my platforms are broken:

2018-05-05 16:08:06 ERROR (MainThread) [homeassistant.components.light] Error while setting up platform lutron_caseta_pro
Traceback (most recent call last):
  File "/home/neal/dev/src/home-assistant/homeassistant/helpers/entity_platform.py", line 125, in _async_setup_platform
    task = async_create_setup_task()
  File "/home/neal/dev/src/home-assistant/homeassistant/helpers/entity_platform.py", line 90, in async_create_setup_task
    None, platform.setup_platform, hass, platform_config,
AttributeError: module 'light.lutron_caseta_pro' has no attribute 'setup_platform'

I tried changing my async_setup_platform to setup_platform and removing the asyncio but it still doesn't work.

I don't know what they have been doing in the Home Assistant code, but it broke everything. :(

cgarwood commented 6 years ago

Looks like there's another PR with fixes related to the custom_components fix, not sure if it will help in this case or not: https://github.com/home-assistant/home-assistant/pull/14317

balloob commented 6 years ago

Custom components should not import from one another. If you want to import other custom components, do this:

# If it's a component
hass.components.casetify.some_method()

# If it's a platfrom
from homeassistant.loader import get_component
platform = get_component(hass, 'light.hue')
czoog commented 6 years ago

Anybody try the released version of 0.69? Does it break this component?

cgarwood commented 6 years ago

The custom_component changes to HomeAssistant were reverted, so this component is working again on the released 0.69 version.

balloob commented 6 years ago

Then close this issue ;)