home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.62k stars 30.77k forks source link

Critical errors when wifi deactivated on freebox component #38695

Closed benjR closed 4 years ago

benjR commented 4 years ago

The problem

I don't use the builtin wifi capabilities of my freebox so I'm getting those errors that are filling up my logs:

Update for switch.freebox_wifi fails                                                                                                                                                                                                                                                        
Traceback (most recent call last):                                                                                                                                                                                                                                                          
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 272, in async_update_ha_state                                                                                                                                                                                         
    await self.async_device_update()                                                                                                                                                                                                                                                        
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 463, in async_device_update                                                                                                                                                                                           
    await self.async_update()  # type: ignore                                                                                                                                                                                                                                               
  File "/usr/src/homeassistant/homeassistant/components/freebox/switch.py", line 75, in async_update                                                                                                                                                                                        
    datas = await self._router.wifi.get_global_config()                                                                                                                                                                                                                                     
  File "/usr/src/homeassistant/homeassistant/components/freebox/router.py", line 186, in wifi                                                                                                                                                                                               
    return self._api.wifi                                                                                                                                                                                                                                                                   
AttributeError: 'NoneType' object has no attribute 'wifi'

Environment

Problem-relevant configuration.yaml

n/a

Traceback/Error logs

Update for switch.freebox_wifi fails                                                                                                                                                                                                                                                        
Traceback (most recent call last):                                                                                                                                                                                                                                                          
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 272, in async_update_ha_state                                                                                                                                                                                         
    await self.async_device_update()                                                                                                                                                                                                                                                        
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 463, in async_device_update                                                                                                                                                                                           
    await self.async_update()  # type: ignore                                                                                                                                                                                                                                               
  File "/usr/src/homeassistant/homeassistant/components/freebox/switch.py", line 75, in async_update                                                                                                                                                                                        
    datas = await self._router.wifi.get_global_config()                                                                                                                                                                                                                                     
  File "/usr/src/homeassistant/homeassistant/components/freebox/router.py", line 186, in wifi                                                                                                                                                                                               
    return self._api.wifi                                                                                                                                                                                                                                                                   
AttributeError: 'NoneType' object has no attribute 'wifi'

Additional information

probot-home-assistant[bot] commented 4 years ago

Hey there @snoof85, @quentame, mind taking a look at this issue as its been labeled with an integration (freebox) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

SNoof85 commented 4 years ago

@Quentame should we fix this in the aiofreepybox lib ?

Quentame commented 4 years ago

@Quentame should we fix this in the aiofreepybox lib ?

Emmmm, don't think so.

Checking this week.

Quentame commented 4 years ago

@Quentame should we fix this in the aiofreepybox lib ?

Not needed, it's on HA side, thanks 😉

Quentame commented 4 years ago

Is the error coming after you remove the integration ?

benjR commented 4 years ago

Nope, just configured it

Quentame commented 4 years ago

Nope, just configured it

Oh ! Okey, reopening then.

How did you configure your Freebox? Bridge mode?

benjR commented 4 years ago

How did you configure your Freebox? Bridge mode?

Nope, it's in router mode with wifi deactivated.

image

SNoof85 commented 4 years ago

Could not reproduce the error.

os131 commented 4 years ago

I'm experiencing the same problem with wifi disabled (I'm using Ubiquiti's Unifi AP) . It was the same with the Freebox mini 4k and now with the Freebox pop. The freebox wifi was off when I've setted the integration. Also it would be great to allow disabelling the trackers on Freebox for those, like us, who use another wifi AP, as every devices are seen in the both integrations (Freebox and Ubiquiti Unifi, for me)


Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 192, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 301, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 472, in _async_add_entity
    await entity.async_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/freebox/sensor.py", line 125, in async_added_to_hass
    self.async_update_state()
  File "/usr/src/homeassistant/homeassistant/components/freebox/sensor.py", line 149, in async_update_state
    for call in self._router.call_list:
TypeError: 'NoneType' object is not iterable```
Quentame commented 4 years ago

@os131 yours is about the call sensor.

Do you have a other error ? (indicating wifi)

SNoof85 commented 4 years ago

@os131 Disabling a platform from an integration is a good point but not sure if doable... Would need an expert/core dev answer ! You can still disable all entities from the device tracker of the Freebox integration and disable new entities auto add for the Freebox integration.

Edit : @Quentame the error with call logs is there when there's no calls in the call log of the Freebox (tested & reproduced !) Will open another issue !)

Opened : #39863

Quentame commented 4 years ago

File "/usr/src/homeassistant/homeassistant/components/freebox/router.py", line 186, in wifi
return self._api.wifi
AttributeError: 'NoneType' object has no attribute 'wifi'```

The log means that _api is None, not the wifi attribute, which can't be None after open a connection with the Freebox.

Can you:

And tell me if the issue still exists.

If it does, after which event ?

os131 commented 4 years ago

@os131 yours is about the call sensor.

Do you have a other error ? (indicating wifi)

Wifi error comes time to time (the first error since your post came this morning). There is no special event that can explain why this error raise up at this moment specificaly.

2020-09-15 08:16:16 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.freebox_wifi fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 964, in _create_direct_connection
    hosts = await asyncio.shield(self._resolve_host(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 964, in _create_direct_connection
    hosts = await asyncio.shield(self._resolve_host(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 815, in _resolve_host
    await event.wait()
  File "/usr/local/lib/python3.8/site-packages/aiohttp/locks.py", line 37, in wait
    raise self._exc
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 829, in _resolve_host
    addrs = await \
  File "/usr/local/lib/python3.8/site-packages/aiohttp/resolver.py", line 29, in resolve
    infos = await self._loop.getaddrinfo(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

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 263, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 454, in async_device_update
    await self.async_update()  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/freebox/switch.py", line 75, in async_update
    datas = await self._router.wifi.get_global_config()
  File "/usr/local/lib/python3.8/site-packages/aiofreepybox/api/wifi.py", line 10, in get_global_config
    return await self._access.get('wifi/config/')
  File "/usr/local/lib/python3.8/site-packages/aiofreepybox/access.py", line 112, in get
    return await self._perform_request(self.session.get, end_url)
  File "/usr/local/lib/python3.8/site-packages/aiofreepybox/access.py", line 90, in _perform_request
    r = await verb(url, **request_params)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _create_connection
    _, proto = await self._create_direct_connection(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 971, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host xxxxxxxx.fbxos.fr:xxxxxx ssl:default [Try again]
2020-09-15 08:16:16 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 964, in _create_direct_connection
    hosts = await asyncio.shield(self._resolve_host(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 964, in _create_direct_connection
    hosts = await asyncio.shield(self._resolve_host(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 815, in _resolve_host
    await event.wait()
  File "/usr/local/lib/python3.8/site-packages/aiohttp/locks.py", line 37, in wait
    raise self._exc
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 829, in _resolve_host
    addrs = await \
  File "/usr/local/lib/python3.8/site-packages/aiohttp/resolver.py", line 29, in resolve
    infos = await self._loop.getaddrinfo(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/freebox/router.py", line 79, in update_all
    await self.update_sensors()
  File "/usr/src/homeassistant/homeassistant/components/freebox/router.py", line 115, in update_sensors
    syst_datas: Dict[str, Any] = await self._api.system.get_config()
  File "/usr/local/lib/python3.8/site-packages/aiofreepybox/api/system.py", line 10, in get_config
    return await self._access.get('system/')
  File "/usr/local/lib/python3.8/site-packages/aiofreepybox/access.py", line 112, in get
    return await self._perform_request(self.session.get, end_url)
  File "/usr/local/lib/python3.8/site-packages/aiofreepybox/access.py", line 90, in _perform_request
    r = await verb(url, **request_params)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _create_connection
    _, proto = await self._create_direct_connection(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 971, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host xxxxxxxx.fbxos.fr:xxxxxx ssl:default [Try again]
Quentame commented 4 years ago

@os131

Wifi error comes time to time (the first error since your post came this morning). There is no special event that can explain why this error raise up at this moment specificaly.

You were having an occasionnal error while the Freebox is busy and did not handle the API call. The sensor should get back to normal at the next update (30s).

The error is not the same as the initial.


@benjR

File "/usr/src/homeassistant/homeassistant/components/freebox/router.py", line 186, in wifi
return self._api.wifi
AttributeError: 'NoneType' object has no attribute 'wifi'```

this means _api is None, and the only mean it can be None is after remove the integration.

A fix has been made on 0.115.0 when sensors try to update after the integration removal, see #38842

benjR commented 4 years ago

Thanks @Quentame I did try to remove and reinstall the integration to test the fix, but I broke something somehow... I did remove the integration from the config panel (after shutting down HA), remove authorizations from freeboxOS to connect, remove the freebox folder in .storage, restarted and added back, accepted on the freebox delta panel, but now I don't have anything.

Trace here, I'll open another issue for this.

Please confirm the authentification on the freebox                                                                                                                                                                                                                                          
2020-10-30 09:34:56 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 9ufqaq4a.fbxos.fr for freebox                                                                                                                                                                  
Traceback (most recent call last):                                                                                                                                                                                                                                                          
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 234, in async_setup                                                                                                                                                                                                   
    result = await component.async_setup_entry(hass, self)  # type: ignore                                                                                                                                                                                                                  
  File "/usr/src/homeassistant/homeassistant/components/freebox/__init__.py", line 65, in async_setup_entry                                                                                                                                                                                 
    await router.setup()                                                                                                                                                                                                                                                                    
  File "/usr/src/homeassistant/homeassistant/components/freebox/router.py", line 75, in setup                                                                                                                                                                                               
    await self.update_all()                                                                                                                                                                                                                                                                 
  File "/usr/src/homeassistant/homeassistant/components/freebox/router.py", line 82, in update_all                                                                                                                                                                                          
    await self.update_sensors()                                                                                                                                                                                                                                                             
  File "/usr/src/homeassistant/homeassistant/components/freebox/router.py", line 123, in update_sensors                                                                                                                                                                                     
    self.sensors_temperature[sensor["name"]] = sensor["value"]                                                                                                                                                                                                                              
KeyError: 'value'                                               
Quentame commented 4 years ago

Yep, please create a new issue. Thanks