Show a notification when a config entry is discovered#14022
Merged
Conversation
027ff34 to
119baeb
Compare
| await async_setup_component( | ||
| self.hass, entry.domain, self._hass_config) | ||
|
|
||
| # remove notification if 0 flows with discovery source in progress |
Member
There was a problem hiding this comment.
This comment sounds weird looking at the code below it. I don't get it.
Member
There was a problem hiding this comment.
I like the idea behind this code and make it faster but the comment was wrong
Member
Author
There was a problem hiding this comment.
When we finish the last config flow that has source=discovery, we should remove the notification.
Member
There was a problem hiding this comment.
Yes, but that's not what the code is doing. This comment was a misplaced duplicate from the one below.
pvizeli
approved these changes
Apr 21, 2018
houndci-bot
reviewed
Apr 21, 2018
| hass.components.persistent_notification.async_create( | ||
| title='New devices discovered', | ||
| message=("We have discovered new devices on your network. " | ||
| "[Check it out](/config/integrations)"), |
There was a problem hiding this comment.
continuation line under-indented for visual indent
|
|
||
| # Create notification. | ||
| if source in DISCOVERY_SOURCES: | ||
| hass.components.persistent_notification.async_create( |
| # If no discovery config entries in progress, remove notification. | ||
| if not any(ent['source'] in DISCOVERY_SOURCES for ent | ||
| in self.hass.config_entries.flow.async_progress()): | ||
| hass.components.persistent_notification.async_dismiss( |
houndci-bot
reviewed
Apr 21, 2018
| hass.components.persistent_notification.async_create( | ||
| title='New devices discovered', | ||
| message=("We have discovered new devices on your network. " | ||
| "[Check it out](/config/integrations)"), |
There was a problem hiding this comment.
continuation line under-indented for visual indent
|
|
||
| # Create notification. | ||
| if source in DISCOVERY_SOURCES: | ||
| hass.components.persistent_notification.async_create( |
| # If no discovery config entries in progress, remove notification. | ||
| if not any(ent['source'] in DISCOVERY_SOURCES for ent | ||
| in self.hass.config_entries.flow.async_progress()): | ||
| hass.components.persistent_notification.async_dismiss( |
pvizeli
approved these changes
Apr 22, 2018
Merged
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description:
When we migrated Hue to use config entries for discovery, the user was no longer notified when we discovered it. This will reinstate that behavior with a generic notification for any config flow that is initiated by discovery. We will also automatically dismiss the notification when all discovered flows are finished.
Example entry for
configuration.yaml(if applicable):discovery:Checklist:
tox. Your PR cannot be merged unless tests passIf the code does not interact with devices: