Skip to content
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

IGD review fixes #17400

Merged
merged 7 commits into from
Oct 23, 2018
Merged

IGD review fixes #17400

merged 7 commits into from
Oct 23, 2018

Conversation

StevenLooman
Copy link
Contributor

Description:

Changes after review by @balloob

Related issue (if applicable): fixes #16300

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@ghost ghost added the in progress label Oct 13, 2018
@dgomes dgomes changed the title Igd review fixes UPnP:IGD review fixes Oct 13, 2018
@fabaff fabaff changed the title UPnP:IGD review fixes IGD review fixes Oct 13, 2018
@@ -31,7 +30,7 @@


REQUIREMENTS = ['async-upnp-client==0.12.4']
DEPENDENCIES = ['http']
DEPENDENCIES = ['http', 'discovery']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually thinking, why is it that we need both http and discovery to begin with?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discovery is required as the device is detected via upnp/M-SEARCH.
http is required to determine the port home assistant is listening on (really only used the port mapping is enabled.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that is not needed for running this component, the SSDP response is stored in the config entry.

I think that we should remove both http and discovery, because marking it as dependencies means that we're setting it up.

If port mapping is enabled but http is not enabled: don't setup port mapping.
Not requiring discovery: nothing breaks?.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get a SSDP response discovery is enabled already. The original component already (only) worked with discovery, but used its own library for it. Now the component is using more existing libraries, such as netdisco and async_upnp_client (used also by the dlna_dmr-component).

The 'externals' (config, workings from the perspective of the user, etc) are mostly kept the same compared to the original upnp component. Thus, depending on the http component for getting the hass-port for port mapping. discovery is required as the user has (as before) no way to manually enter a SSDP description URL. Learned from the dlna_dmr component, finding this URL is hard for the average user and discovery is preferable.

I get your point and I'm fine with not requiring these, but then there should be:

  • a message in the logs clearly stating that discovery is required otherwise it will not work (as before)
  • a message in the docs clearly stating that discovery is required otherwise it will not work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Philips Hue will, during their config flow, do their own discovery to find the device. The upnp component should do the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That what is the purpose of netdisco/discovery if every component has to do its own discovery? This feels like unnecessary duplication of functionality, and hence, more suspect to bugs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It serves as purpose to find config entries. However, manual config entries will have to rely on their own scanning logic.

@balloob
Copy link
Member

balloob commented Oct 16, 2018

btw I notice that you're calling get_local_ip inside an async context in upnp/device.py. That call does I/O.

@StevenLooman
Copy link
Contributor Author

StevenLooman commented Oct 16, 2018

btw I notice that you're calling get_local_ip inside an async context in upnp/device.py. That call does I/O.

Creating port mappings does I/O as well. Where do you suggest to do it?

@balloob
Copy link
Member

balloob commented Oct 18, 2018

Outside the event loop. No I/O allowed inside it.

ip = await hass.async_add_executor_job(get_local_ip)

@@ -31,7 +31,7 @@


REQUIREMENTS = ['async-upnp-client==0.12.7']
DEPENDENCIES = ['http']
DEPENDENCIES = ['discovery']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not depend on discovery.

@ghost ghost assigned balloob Oct 21, 2018
@StevenLooman
Copy link
Contributor Author

Work has been slow, but will pick this up soon.

@balloob balloob merged commit fc8af22 into home-assistant:dev Oct 23, 2018
@ghost ghost removed the in progress label Oct 23, 2018
@balloob
Copy link
Member

balloob commented Oct 23, 2018

It's already ok, will merge it. I removed the discovery dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants