Device tracker - Freebox - Access Token query repeated till infinity

Hello,

First of all, I am a newbie here. First post, install HA on an old Raspberry B (B3+ coming soon) last night.
I am a professional developer and not afraid of doing code and PRs (even if my python still lack some practice).

I succeed in setting up light (hue), media player (chrome cast).

I saw in the logs that the discovery of device tracker tried to connect to my Freebox. So I tried to pair both of them in order to try device detection.
At first, the log displayed Authentication timeout (since I did not press the Freebox access token acceptance button).
I couldnt find a way to restart discovery without restart the hassio.
So I went to configure it as explained in the documentation of device_tracker and freebox. Restarted it. I started receiving multiple access token queries on the Freebox (accept one, another arrives). Once one is accepted, the known devices file appeared.
HA successfully pulled the connected device. But ask for a new token.

Even if I let it that way. As he know my smartphone, he can’t see if it is home or not since he can’t connect to the Freebox anymore, he prefers asking for a token.

I tried removing the Freebox.conf file and known device file but now the logs says it get timeout on the connection to the device tracker and do not query token anymore.

Did I do anything that trigger the repeat access token query ?
Is there a simpler way to restart discovery without restart it ? (it takes at least 5 minutes to boot up…)
Is there still some configuration running for the device ? How can I reset it ?

Thanks for your time :slight_smile:

Known issue : Freebox device tracker

As workaround, when you see that the first token worked and your device tracker works also, disable the ability of new token on the freebox. Then there will be no more token asked and device tracker will continue to work.

Could you please file an “official” bug report on the home assistant github, so that I can keep track on the issue and work on it? Thanks!

I created an issue : https://github.com/home-assistant/home-assistant/issues/16934

I would gladly help you if you want.
My dev env isn’t set yet but shouldn’t take too much time to set

I updated the issue with all the data I could gather.

Did not find any work around. I just feel it’s a read right on the Freebox.conf file or configuration folder

Edit : tried ssh and chmod 777 on both Freebox and config folder but still no success

@HolyNoodle Regarding your question about discovery, I don’t know for sure if it’s possible to relaunch it after startup but I don’t think so. For the Freebox component, I would like to rework the initial setup to use either the configurator component or the new config flow at some point, because asking the user to perform a task in the log is not the best UX :smile:!

For the infinite token request issue, I don’t know what could be the cause. I will try to add some more detailed logging on error, to have more info. I see on the GitHub issue that your setup is working now, I’m glad you’re not stuck!

I moved to an Archer C9 as the device tracker in front of the Freebox. The server is 6 years old, it can’t manage so much devices, it fails too much.

Yeah it started to work without any action on my end. I don’t think this is a good point :smiley:

I’ve got a big problem with freebox component , lot of error

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

Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/init.py”, line 180, in async_setup_platform
hass, p_config, tracker.async_see, disc_info)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/freebox.py”, line 51, in async_setup_scanner
await scanner.async_start(hass, interval)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/freebox.py”, line 96, in async_start
await self.async_update_info()
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/freebox.py”, line 106, in async_update_info
await self.fbx.open(self.host, self.port)
File “/usr/local/lib/python3.6/site-packages/aiofreepybox/aiofreepybox.py”, line 64, in open
self._access = await self._get_freebox_access(host, port, self.api_version, self.token_file, self.app_desc, self.timeout)
File “/usr/local/lib/python3.6/site-packages/aiofreepybox/aiofreepybox.py”, line 101, in _get_freebox_access
app_token, track_id = await self._get_app_token(base_url, app_desc, timeout)
File “/usr/local/lib/python3.6/site-packages/aiofreepybox/aiofreepybox.py”, line 165, in _get_app_token
r = await self.session.post(url, data=data, timeout=timeout)
File “/usr/local/lib/python3.6/site-packages/aiohttp/client.py”, line 370, in _request
timeout=timeout
File “/usr/local/lib/python3.6/site-packages/aiohttp/connector.py”, line 445, in connect
proto = await self._create_connection(req, traces, timeout)
File “/usr/local/lib/python3.6/site-packages/aiohttp/connector.py”, line 757, in _create_connection
req, traces, timeout)
File “/usr/local/lib/python3.6/site-packages/aiohttp/connector.py”, line 879, in _create_direct_connection
raise last_exc
File “/usr/local/lib/python3.6/site-packages/aiohttp/connector.py”, line 862, in _create_direct_connection
req=req, client_error=client_error)
File “/usr/local/lib/python3.6/site-packages/aiohttp/connector.py”, line 829, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host q22rhhbm.fbxos.fr:12245 ssl:None [Network unreachable]"

Can you help me ?

Edit: i desinstall it and get error message when i restart Hass…

are you sure that the host and port are correct in your configuration ? Looks like it can’t connect to the router. Otherwise please also check in the Freebox web interface in “paramètres de la freebox” => “gestion des accès” => Applications => the checkbox “permettre les nouvelles demandes d’associations” must be checked !

Yes all the setting look good but that doesn’t work , and when i delete freebox from config yaml , i’ve always get an error …

what kind of freebox do you have ? (revolution / mini / crystal ?)
Can you post here what you get when you fo to this : http://mafreebox.freebox.fr/api_version from the same network that the router ?

Did you checked that the checkbox i spoke about on my previous post was checked ?

And you should also check in the router web interface if you can see the authorized hass app in “gestion des accès”.

Hi , i’ve got the revolution , look at the results when i clcik on the link :
{“api_domain”:“q22rhhbm.fbxos.fr”,“uid”:“65633891bb6491f0568751f360c0f40c”,“https_available”:true,“https_port”:12245,“device_name”:“Freebox Server”,“api_version”:“5.0”,“api_base_url”:"/api/",“device_type”:“FreeboxServer1,2”}

I’ve got the box “cheked” but i’ve got nothing in authorized apps…

OK, back to basis :slight_smile:

  • Your HASS installation runs in the same network than the freebox ?
  • The freebox is in router mode ? not bridge
  • When HASS starts, it should be asked on the freebox screen (as you have the revolution) if you want to autorize the application to connect to the router (you will have to press the right arrow to accept)
  • Can you setup a password on your freebox ? This is the main difference i have with your setup on the screeshot you post. I see that the checkbox “Activer l’authentification par mot de passe” is not checked.
  • In the tab “Applications” of the screenshot you made you have nothing at all ?
  • Can you try the app Freebox compagnon for Android or iOS ? (phone connected to the wifi of the freebox)

And your config was correct according to what you get with the result of the link i gave you :+1:

1 Like

Thanks for your help :slight_smile: SOLVED

  • My HASS is in the same Network

  • The Freebox is in Router mode

  • When Hass start he NEVER ASK to autorize the application to connect , i’ll try the app Freebox compagnon …
    *So Freebox compagnon works well and ask to authorize the app , all works fine for compagnon.

  • i add a password to my freebox and i thnk that it was THE SOLUTION !!..

  • So YES it work fine and i get my freebox.conf …

  • But now i’ve got a lot off error caused by the app who ask for new autorisation ?

  • So i try to uncheked the chekbox “permettre les nouvelles demandes d’associations” and restart…
    OK after restart i don’t have any error regarding Freebox !!
    Thanks you !!

The token is asked in an infinite loop and I’m currently working on it. The workaround is : as soon as the freebox.conf file has been created you have to restart HA. Or uncheck the box you mentioned.
Glad it’s working now :wink:
We’ll have to add to the documentation that a password must be set on the Freebox.

1 Like