deCONZ config entry#13402
Conversation
| errors = {} | ||
|
|
||
| if user_input is not None: | ||
| api_key = await async_get_api_key(self.hass.loop, **self.deconz_config) |
There was a problem hiding this comment.
line too long (83 > 79 characters)
| return False | ||
|
|
||
|
|
||
| async def async_unload_entry(hass, entry): |
There was a problem hiding this comment.
Remove this. We don't support unloading platforms yet and so you are not removing all the entities that this config entry has created.
| @@ -186,3 +187,92 @@ async def async_configuration_callback(data): | |||
| entity_picture="/static/images/logo_deconz.jpeg", | |||
There was a problem hiding this comment.
Please remove all the configurator code.
There was a problem hiding this comment.
Is it ok that I do this when I've migrated the discovery part?
|
All config flows will need 100% test coverage. |
|
|
||
| async def async_setup_entry(hass, entry): | ||
| """Set up a bridge for a config entry.""" | ||
| result = await async_setup_deconz(hass, None, entry.data) |
There was a problem hiding this comment.
What if a user has a host configured and has a config entry for the same host?
There was a problem hiding this comment.
Of course, I will make sure to check in both setups as well.
| """Handle a flow start.""" | ||
| from pydeconz.utils import async_discovery | ||
|
|
||
| if DOMAIN in self.hass.data: |
There was a problem hiding this comment.
So you cannot create a config entry if you have one configured, but you will be able to configure a host after you have created a config entry?
There was a problem hiding this comment.
If there is an instance of deconz running, the config flow won't run. What do you mean by "but you will be able to configure a host after you have created a config entry"?
|
Then I can start learning how to write tests 👍 |
|
100% of the config flow. |
|
See #13034 for inspiration |
|
What is the quickest way to run only my tests? |
|
| result['data_schema']({'host': '1.2.3.4'}) | ||
| result['data_schema']({'host': '5.6.7.8'}) | ||
|
|
||
|
|
|
|
||
| import homeassistant.components.deconz as deconz | ||
|
|
||
| from tests.common import MockConfigEntry, mock_coro |
There was a problem hiding this comment.
'tests.common.MockConfigEntry' imported but unused
'tests.common.mock_coro' imported but unused
| @@ -0,0 +1,90 @@ | |||
| """Tests for deCONZ config flow.""" | |||
| import asyncio | |||
| from unittest.mock import Mock, patch | |||
There was a problem hiding this comment.
'unittest.mock.Mock' imported but unused
'unittest.mock.patch' imported but unused
| @@ -0,0 +1,90 @@ | |||
| """Tests for deCONZ config flow.""" | |||
| import asyncio | |||
Add pydeconz to list of test components
|
@balloob what do you think. Is this enough for a first iteration of configuration entries? I'm ready to start working on discovery and other parts when your PR has been merged 👍🏻 |
|
|
||
| async def async_setup(hass, config): | ||
| """Set up services and configuration for deCONZ component.""" | ||
| if DOMAIN in hass.data: |
There was a problem hiding this comment.
This will never happen. Home Assistant already takes care of this.
|
This looks good! Ok to merge after that one check has been removed. |
Description:
Basic config entry support for deCONZ component
Checklist:
tox. Your PR cannot be merged unless tests pass