Integration install uPNP Config Flow Error

I am consistently getting errors from uPnP while trying to install the integration. It gave me a Config Flow Error and I have tried to resolve this, but without success. Can anyone assist?

Error

Config flow could not be loaded

Here is the error log:

Logger: aiohttp.server
Source: components/upnp/device.py:90
First occurred: 12:40:50 PM (1 occurrences)
Last logged: 12:40:50 PM

Error handling request
Traceback (most recent call last):
File “/usr/local/lib/python3.8/xml/etree/ElementTree.py”, line 1693, in feed
self.parser.Parse(data, 0)
xml.parsers.expat.ExpatError: mismatched tag: line 2, column 219

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py”, line 422, in _handle_request
resp = await self._request_handler(request)
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py”, line 499, in _handle
resp = await handler(request)
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py”, line 119, in impl
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/security_filter.py”, line 56, in security_filter_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/request_context.py”, line 18, in request_context_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/ban.py”, line 72, in ban_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/auth.py”, line 129, in auth_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/view.py”, line 129, in handle
result = await result
File “/usr/src/homeassistant/homeassistant/components/config/config_entries.py”, line 117, in post
return await super().post(request)
File “/usr/src/homeassistant/homeassistant/components/http/data_validator.py”, line 60, in wrapper
result = await method(view, request, *args, **kwargs)
File “/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py”, line 69, in post
result = await self._flow_mgr.async_init(
File “/usr/src/homeassistant/homeassistant/data_entry_flow.py”, line 133, in async_init
result = await self._async_handle_step(
File “/usr/src/homeassistant/homeassistant/data_entry_flow.py”, line 216, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File “/usr/src/homeassistant/homeassistant/components/upnp/config_flow.py”, line 80, in async_step_user
discoveries = [
File “/usr/src/homeassistant/homeassistant/components/upnp/config_flow.py”, line 81, in
await Device.async_supplement_discovery(self.hass, discovery)
File “/usr/src/homeassistant/homeassistant/components/upnp/device.py”, line 72, in async_supplement_discovery
device = await Device.async_create_device(hass, location)
File “/usr/src/homeassistant/homeassistant/components/upnp/device.py”, line 90, in async_create_device
upnp_device = await factory.async_create_device(ssdp_location)
File “/usr/local/lib/python3.8/site-packages/async_upnp_client/client_factory.py”, line 52, in async_create_device
root = await self._async_get_url_xml(description_url)
File “/usr/local/lib/python3.8/site-packages/async_upnp_client/client_factory.py”, line 295, in _async_get_url_xml
root = DET.fromstring(response_body) # type: ET.Element
File “/usr/local/lib/python3.8/site-packages/defusedxml/common.py”, line 131, in fromstring
parser.feed(text)
File “/usr/local/lib/python3.8/xml/etree/ElementTree.py”, line 1695, in feed
self._raiseerror(v)
File “/usr/local/lib/python3.8/xml/etree/ElementTree.py”, line 1602, in _raiseerror
raise err
File “”, line None
xml.etree.ElementTree.ParseError: mismatched tag: line 2, column 219

Please provide more info: what kind of device are you trying to add as a UPnP integration?
From the documentation https://www.home-assistant.io/integrations/upnp/ it looks like you only need to provide the IP address. Is that what you are entering?
Also make sure to read the Troubleshooting paragraph.

It is a Raspberry Pi 3 with Hassio installed. FYI, I have not even gotten to the point of adding the IP address into the integration. The integration keeps getting locked up while intstalling or gives me the error above. I will take the time to read the troubleshooting paragraph again.

Then I’d suggest creating an issue here: https://github.com/home-assistant/core/issues
The uPnP integration codeowner will probably want to know about this error.

Went ahead and submitted my log and the error. Anyone else have good suggestions?

i’m having the same problem, any news about the problem?

My upnp all poped up by themselves. I’m guessing you already connected the device and it wasn’t automatically discovered? Have you removed or at least disabled upnp on the device you were trying to connect in the first place?

Maybe the device is stopping the integration. It seems it can be added, the integration, without a device by adding

upnp:

to your config file.

Yeah I was thinking of manually adding it as you suggested, but I can’t even install the integration in the first place. So maybe by manually adding the device, it will work. Just trying to stay away from legacy installation.

Nothing resolved on my end yet

That’s not what I was suggesting. I assume you have a upnp device, the one you want to connect to HA, yes?

I’m suggesting that if the upnp device is currently connected to your network, disconnect it. Then try to add the integration to HA without any other upnp devices on the network.

I quickly investigated the error a bit. Looks like your device (you still haven’t told us what brand/type the problem-device is…) doesn’t provide complete/readable data back. And, the error is in the async_upnp_client library. I’ve also noticed that this backend library is being updated. You might try copying the HA Core issue to here: https://github.com/StevenLooman/async_upnp_client/issues if there is no response to the issue you’ve created on the HA Core github.

The device is a TPLink Archer C9 Router. The error comes before device selection and it always gets hung up on the installation of the actual integration. I don’t even get to the point to where I choose a device. I have posted into core github and there has been a response but have not gotten anything resolved yet.

You could make a upnp custom_component from the HA Core upnp-component files and try the newer versions of async_upnp_client to see whether the error already has been solved?

Is upnp disabled on the router? You should be able to disable upnp in the router settings. If the error is as Bouwe suggested,

disabling upnp on the router should allow you to at least add the integration. If the integration still doesn’t install at that point, something else is causing the error.

When you do that, the upnp-integration will not find the device. It will throw an abort message and will not install. I’ve tried this yesterday in my HA Core system.

1 Like

Yes you are correct I should have tried it myself. Taking a quick look I found a CLI for collecting network stats for an archer c9. It mentions that statistics needs to be enabled on the router. I’d assume that upnp would require this to be enabled as well.

Statistics collection must be enabled on the router, under Advanced > System Tools > Statistics . As a requirement of statistics collection, the router must have the “NAT Boost” setting turned off, under Advanced > NAT Boost .

Great catch. I will look into this immediately. I found the settings in my router on statistics being turned off and now it’s a decision if the statistics are worth it or do I turn off NAT Boost.

Ok interesting. When I turn uPnP off on the router it gives me a message of “No devices found on the network”. When I turn it back on and try install again it has the same error “Config flow cound not be loaded”. In order to get statistics off the router, I will need ot shut off NAT Boost (which handles high speed traffic on the router), so I guess I am stuck on not getting the statistics from this router into Home Assistant. I could use SNMP, but trying to find the OID is impossible and even if I could I might be just right back to where I am now. IF the statistics are not being generated by the router, then there is no way home assistant will pick it up. Which isn’t a big deal. Just thinking this one out. What do you guys think?

I believe there are also other options to get netstats, a pihole or prometheus. It would require you to have a docker environment or set up another pi though.