-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Delay device discovery during WeMo component initialization. #4435
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
Conversation
Schedule device discovery to run after the WeMo component has finished initializing. This avoids a situation where initialization fails because discovery triggered initialization of two WeMo platforms that both try to setup the WeMo component.
I don't think that I fully understand your description. We only setup each component once. Discovery will wait doing setup until setup component is done. |
I was seeing errors that the WeMo component was already being initialized. The component is loaded either from the config because of a The wemo component initialization takes quite a bit of time because it runs its own pywemo.discovery ans during this time another platform, for instance On November 17, 2016 10:29:56 AM EST, Paulus Schoutsen notifications@github.com wrote:
|
But as far as I know, the discovery component doesn't start discovery till On Thu, Nov 17, 2016, 07:36 Jan Harkes notifications@github.com wrote:
|
I don't have wemo in my config at all, as well as chromecast and various others. Discovery is what gets those platforms and components loaded. On November 17, 2016 10:52:00 AM EST, Paulus Schoutsen notifications@github.com wrote:
|
I think we may be talking about different device discoveries here because of my poor choice of wording for the PR description.
What this patch delays is a call to `pywemo.discover_devices`, not the device discovery using netdisco in the discovery component. The WeMo specific discovery duplicates what netdisco does, possibly in a slightly different way and is supposedly for people who want only their WeMo devices autodiscovered and to make the component more robust.
My argument against it is that it duplicates existing functionality and only does a one-time shot discovery during startup, while netdisco periodically rescans in the background and will be able to see devices that come online after hass is already running.
|
What is happening currently:
I think that the problem is not inside the wemo component but it is a problem inside the discovery helpers. The discover method should be made async and also acquire a lock just like |
So by making the component setup faster, I just made the window for the race condition smaller, but the problem is still there. |
I have resolved the discovery issue in #4463 👍 |
#4463 did not seem to have resolved the issue. Yesterday I ran 0.34.dev0 with only a change to revert the netdisco dependency back to 0.7.5. I've extracted relevant parts of the log,
|
Oh I think that I see the problem. Can you add |
👍 that does the trick. |
Description:
When network discovery finds multiple WeMo platforms (in my case switch and light) then both platforms depend on the WeMo component. Because we are running a one-shot discovery during component initialization which takes some time the second initialization failed.
This patch delays running the pywemo specific discovery to occur after the component initialization has completed.
Related issue (if applicable): fixes #
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 passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests passSchedule device discovery to run after the WeMo component has finished
initializing. This avoids a situation where initialization fails because
discovery triggered initialization of two WeMo platforms that both
try to setup the WeMo component.