UPnP looses the sensors every time I restart the Home assistant

I’ve got a few sensors from my Fritz!Box router showing upload/download speed through UPnP.
But every time I restart the HA in the later versions, it looses the sensors, and I have to remove the UPnP and reconfigure it to get them back?

1 Like

There’s a PR to fix this that @balloob has tagged for 0.92.2

1 Like

Sounds great, thankyou. Where do I find the PR’s?

This is still not solved, and we’re are 0.94.2?
It changes name on reboot, last reboot, it was called:
This reboot it’s called:

Those are seperate sensors I think… I find about 50% or the time they are detected and 50% not as before. The PR didn’t fix this unfortunately.

It’s the same unit.
I have to go and delete the UPnP integration and reactivate it to get them shown again.
When I do that it changes names.

It’s a different sensor… one is in kbytes the other is packets… (Yes 1 device but I get 8 sensors when it works)

Ahh, ok, that just a question of copy pasting the wrong line :slight_smile:
The change in name is still happening on every boot
It’s currently sensor.fritz_box_7560_kbyte_sec_received
It was previously sensor.internetgatewaydevicev2_fritz_box_7560_kbyte_sec_received

Well that’s ‘odd’ Mine are all as per your ‘previously’ example.

I just retested it, after a reboot, it’s again unknown.
After reestablishing it, it got the same name this time.

I’m seeing this same issue. The entities become ‘not available’ and I’m unsure how to fix this.

I enabled logging for this component and all I get is:

Sep 25 00:29:39 nixserver hass[5505]: 2019-09-25 00:29:39 INFO (MainThread) [homeassistant.bootstrap] Setting up {‘system_log’, ‘logger’}
Sep 25 00:29:39 nixserver hass[5505]: 2019-09-25 00:29:39 INFO (MainThread) [homeassistant.setup] Setting up logger
Sep 25 00:29:40 nixserver hass[5505]: 2019-09-25 00:29:40 DEBUG (MainThread) [homeassistant.components.upnp] Discovering UPnP/IGD devices
Sep 25 00:29:51 nixserver hass[5505]: 2019-09-25 00:29:51 INFO (MainThread) [homeassistant.components.upnp] No UPnP/IGD devices discovered
Sep 25 00:29:51 nixserver hass[5505]: 2019-09-25 00:29:51 INFO (MainThread) [homeassistant.components.upnp] Unable to create UPnP/IGD, aborting

For the later versions, I’ve seen a stability increase in this. Are you on the latest version?

Yes, I’m on the latest version. I just installed HA last week.

Same problem here.
I have an ASUS rt-AC6U router.
With the default discovery install, every time I restarted Home Assistant, the uPNP integration was trashed with all sensors unavailable. Deleting and reactivating the integration restored the sensors. The sensor names did not change, nor did the integration name.
Running latest HASS.IO on RPi2
All other integrations (tado, rflink, deCONZ survived intact)
Then tried adding

  sensors: true
  local_ip: "192.local.hassio.IP"

to the configuration.yaml file and the integration seemed to have survive the first restart. However, subsequent restarts still trashed the integration. :frowning:

1 Like

Further to the last.
It appears the problem is due to timeouts caused by a slow(ish) processor/network access.
There was an earlier thread that addressed this by increasing the discovery timeout from 4s to 10s.
I solved my problem by offloading the SQL server onto another machine - better for the uSD card and the health of the Pi all round (lower operating temperature and lower CPU load). This seems to have allowed it to respond more quickly to the discovery process and I have not lost uPNP integration in the several restarts since.

It looks like that was included as part of 0.96: https://github.com/home-assistant/home-assistant/pull/25205

I’m running 0.99.3, so it seems the code change did not fully correct the issue.

I have similar problem. After a while the UPNP just fails working. Sensors won’t get any values

Update for sensor.rt_ac68u_bytes_sent fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 954, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 941, in create_connection
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 464, in sock_connect
    return await fut
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 494, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('', 47779)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 270, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 448, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/upnp/sensor.py", line 143, in async_update
    self._state = await self._device.async_get_total_bytes_sent()
  File "/usr/src/homeassistant/homeassistant/components/upnp/device.py", line 151, in async_get_total_bytes_sent
    return await self._igd_device.async_get_total_bytes_sent()
  File "/usr/local/lib/python3.7/site-packages/async_upnp_client/profiles/igd.py", line 99, in async_get_total_bytes_sent
    result = await action.async_call()
  File "/usr/local/lib/python3.7/site-packages/async_upnp_client/client.py", line 509, in async_call
    await self.service.requester.async_http_request('POST', url, headers, body)
  File "/usr/local/lib/python3.7/site-packages/async_upnp_client/client.py", line 70, in async_http_request
  File "/usr/local/lib/python3.7/site-packages/async_upnp_client/aiohttp.py", line 103, in async_do_http_request
    async with self._session.request(method, url, headers=headers, data=body) as response:
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 483, in _request
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 859, in _create_connection
    req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 986, in _create_direct_connection
    req=req, client_error=client_error)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host ssl:None [Connect call failed ('', 47779)]

Issue opened

I think this issue is unnecessarily specific to the Asus platform and the usage of Pi-hole.
The more generic issue would probably be this one: