-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Add discovery notify support and mysensors notify #4014
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
Add discovery notify support and mysensors notify #4014
Conversation
@MartinHjelmare, thanks for your PR! By analyzing the history of the files in this pull request, we identified @kaustubhphatak, @OttoWinter and @mxtra to be potential reviewers. |
Don't merge! Need to rebase this when #4013 is merged. |
Code looks fine with me 🐬 . You can merge this when you are ready. |
I'll postpone merging this until after 0.32 release. If possible I'd like to setup the platform via discovery, but I haven't looked into what that would take yet. |
Bump |
62ba635
to
87e5048
Compare
I've added possibility of using discovery for notify platforms. I'd like @balloob to look at this, if it's viable. As discussed in gitter, I've been experiencing occasional, 1/3 - 1/5 of every start, race conditions with this branch where the notify component is setup more than once. We don't want this to happen! https://gitter.im/home-assistant/home-assistant/devs?at=58289aecdf5ae966454fe218 From how I'm reading the code and from my testing it looks like this is due to how the With that said, I'd love to be proven wrong, or that we find a better way to implement discovery for notify platforms. |
Sorry for not getting back to you earlier. You are right here about the locking not being correct. I think an easy fix for this is to acquire the lock inside |
I have resolved the discovery issue in #4463 |
87e5048
to
eab3160
Compare
})) | ||
# Platform should not be set up, but component should be set up. | ||
with assert_setup_component(0): | ||
self.assertTrue(setup_component(self.hass, notify.DOMAIN, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the change to notify component this test doesn't add value anymore, I think. The notify component will be set up even with bad config, due to config validation removing the bad parts.
with assert_setup_component(0): | ||
assert not setup_component(self.hass, notify.DOMAIN, { | ||
assert setup_component(self.hass, notify.DOMAIN, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the change to notify component this test doesn't add value anymore, I think. The notify component will be set up even with bad config, due to config validation removing the bad parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, strip it.
if p_config is None: | ||
p_config = {} | ||
if discovery_info is not None: | ||
p_config = discovery_info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a good idea, using the passed discovery info directly as config for the platform?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
I have made another fix for the discovery today #4529 |
|
||
for platform, p_config in config_per_platform(config, DOMAIN): | ||
if not setup_notify_platform(platform, p_config): | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic in bootstrap will actually continue setting up platforms after it finds invalid platforms. So let's mimic that behavior here.
Bump |
* Make add_devices optional in platform callback function. * Use new argument structure for all existing mysensors platforms. * Add notify platform.
* Enable discovery of notify platforms. * Use discovery to set up mysensors notify platform.
* Continue setup of notify platforms if a platform fails setup. * Remove notify tests that check platform config. These tests are not needed when config validation is used. * Add config validation to APNS notify platform.
eab3160
to
4b994c6
Compare
@@ -6,7 +6,7 @@ | |||
|
|||
from homeassistant.bootstrap import setup_component | |||
import homeassistant.components.notify as notify | |||
from tests.common import get_test_home_assistant | |||
from tests.common import assert_setup_component, get_test_home_assistant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'assert_setup_component' imported but unused
One lint violation and some tests for notify component is still missing. I'll fix that asap. |
This PR seems to have gone stale. Closing it. You can reopen it when you're ready to finish it. |
Description:
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests pass