-
-
Notifications
You must be signed in to change notification settings - Fork 37.5k
Hass.io discovery flow deconz #22623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c8ddd95
Add Hass.io deCONZ discovery flow
pvizeli 9935080
add bridge ID
pvizeli fc370be
fix attribute
pvizeli 80256e2
fix strings
pvizeli d1a18b5
Address comments
pvizeli 034f9fe
Add test
pvizeli 1b46d23
Add only instance / changed maybe later
pvizeli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,18 @@ | ||
| """Config flow to configure deCONZ component.""" | ||
| import asyncio | ||
|
|
||
| import async_timeout | ||
| import voluptuous as vol | ||
|
|
||
| from homeassistant import config_entries | ||
| from homeassistant.core import callback | ||
| from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT | ||
| from homeassistant.core import callback | ||
| from homeassistant.helpers import aiohttp_client | ||
|
|
||
| from .const import ( | ||
| CONF_ALLOW_DECONZ_GROUPS, CONF_ALLOW_CLIP_SENSOR, DEFAULT_PORT, DOMAIN) | ||
|
|
||
| CONF_BRIDGEID = 'bridgeid' | ||
| CONF_ALLOW_CLIP_SENSOR, CONF_ALLOW_DECONZ_GROUPS, CONF_BRIDGEID, | ||
| DEFAULT_ALLOW_CLIP_SENSOR, DEFAULT_ALLOW_DECONZ_GROUPS, DEFAULT_PORT, | ||
| DOMAIN) | ||
|
|
||
|
|
||
| @callback | ||
|
|
@@ -28,6 +29,8 @@ class DeconzFlowHandler(config_entries.ConfigFlow): | |
| VERSION = 1 | ||
| CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_PUSH | ||
|
|
||
| _hassio_discovery = None | ||
|
|
||
| def __init__(self): | ||
| """Initialize the deCONZ config flow.""" | ||
| self.bridges = [] | ||
|
|
@@ -151,8 +154,10 @@ async def async_step_options(self, user_input=None): | |
| return self.async_show_form( | ||
| step_id='options', | ||
| data_schema=vol.Schema({ | ||
| vol.Optional(CONF_ALLOW_CLIP_SENSOR): bool, | ||
| vol.Optional(CONF_ALLOW_DECONZ_GROUPS): bool, | ||
| vol.Optional(CONF_ALLOW_CLIP_SENSOR, | ||
| default=DEFAULT_ALLOW_CLIP_SENSOR): bool, | ||
| vol.Optional(CONF_ALLOW_DECONZ_GROUPS, | ||
| default=DEFAULT_ALLOW_DECONZ_GROUPS): bool, | ||
| }), | ||
| ) | ||
|
|
||
|
|
@@ -191,3 +196,45 @@ async def async_step_import(self, import_config): | |
| user_input = {CONF_ALLOW_CLIP_SENSOR: True, | ||
| CONF_ALLOW_DECONZ_GROUPS: True} | ||
| return await self.async_step_options(user_input=user_input) | ||
|
|
||
| async def async_step_hassio(self, user_input=None): | ||
| """Prepare configuration for a Hass.io deCONZ bridge. | ||
|
|
||
| This flow is triggered by the discovery component. | ||
| """ | ||
| if configured_hosts(self.hass): | ||
| return self.async_abort(reason='one_instance_only') | ||
|
|
||
| self._hassio_discovery = user_input | ||
|
Kane610 marked this conversation as resolved.
|
||
|
|
||
| return await self.async_step_hassio_confirm() | ||
|
|
||
| async def async_step_hassio_confirm(self, user_input=None): | ||
| """Confirm a Hass.io discovery.""" | ||
| if user_input is not None: | ||
| data = self._hassio_discovery | ||
|
|
||
| return self.async_create_entry( | ||
| title=data['addon'], data={ | ||
| CONF_HOST: data[CONF_HOST], | ||
| CONF_PORT: data[CONF_PORT], | ||
| CONF_BRIDGEID: data['serial'], | ||
| CONF_API_KEY: data[CONF_API_KEY], | ||
|
pvizeli marked this conversation as resolved.
|
||
| CONF_ALLOW_CLIP_SENSOR: | ||
| user_input[CONF_ALLOW_CLIP_SENSOR], | ||
| CONF_ALLOW_DECONZ_GROUPS: | ||
| user_input[CONF_ALLOW_DECONZ_GROUPS], | ||
| }) | ||
|
|
||
| return self.async_show_form( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be removed with #22449 So no need to introduce that configuration |
||
| step_id='hassio_confirm', | ||
| description_placeholders={ | ||
| 'addon': self._hassio_discovery['addon'] | ||
| }, | ||
| data_schema=vol.Schema({ | ||
| vol.Optional(CONF_ALLOW_CLIP_SENSOR, | ||
| default=DEFAULT_ALLOW_CLIP_SENSOR): bool, | ||
| vol.Optional(CONF_ALLOW_DECONZ_GROUPS, | ||
| default=DEFAULT_ALLOW_DECONZ_GROUPS): bool, | ||
| }) | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.