ualex73 / slide

Slide Component for Home Assistant
Apache License 2.0
26 stars 8 forks source link

Local API without Cloud API #4

Closed bobvanderlinden closed 2 years ago

bobvanderlinden commented 3 years ago

The README says to configure the cloud API using:

slide:
  username: XXX
  password: XXX

and the local API using:

cover:
  - platform: slide
    host: XXX
    password: XXX

However, whenever I configure the local API without configuring the cloud API, slide will fail to initialize:

2021-03-28 01:30:54 ERROR (MainThread) [homeassistant.setup] Error during setup of component slide
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
result = await task
File "/config/custom_components/slide/__init__.py", line 146, in async_setup
username = config[DOMAIN][CONF_USERNAME]
KeyError: 'slide'

This makes sense, as __init__.py always tries to read the username from its configuration. This fails, because I don't have a slide: section in my configuration.

I added the following to init.py to get around the problem, but I wasn't sure this is just a hack or a proper fix:

    if not DOMAIN in config:
        _LOGGER.debug("Slide Cloud API not configured")
        return True
MartVisser commented 3 years ago

Same issue here, and "fixed" it the same way as @bobvanderlinden

ualex73 commented 2 years ago

Sorry, I didn't see this issue (didn't get an email). I officially put it in the init.py file now, thanks for reporting it!