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
71.07k stars 29.73k forks source link

freebox : Can't reconfigure freebox #43812

Closed benjR closed 2 years ago

benjR commented 3 years ago

The problem

Following this bug report : https://github.com/home-assistant/core/issues/38695#issuecomment-719424439 I deleted my freebox config to add it up again to test if the fix was working as expected, but I can't make it work again.

This is what I did:

Here is what I get now when it starts or just after pairing:

2020-12-01 13:43:07 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry *******.fbxos.fr for freebox
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 236, 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'

Here is what I tried so far after encountering the issue:

Environment

Problem-relevant configuration.yaml

Done via GUI no yaml configuration related

Traceback/Error logs

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 236, 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'

Additional information

Putting info displayed in /api_version

{
"box_model_name": "Freebox v7 (r1)",
"api_base_url": "/api/",
"https_port": 26710,
"device_name": "Freebox Server",
"https_available": true,
"box_model": "fbxgw7-r1/full",
"api_domain": "**********.fbxos.fr",
"uid": "*****************",
"api_version": "8.0",
"device_type": "FreeboxServer7,1"
}

Happy to help/try anything if you have any idea, thanks!

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

freebox documentation freebox source (message by IssueLinks)

probot-home-assistant[bot] commented 3 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)

bbadrignans commented 3 years ago

Same issue for me

SNoof85 commented 3 years ago

Hi both,

Could you tell us what kind of Freebox you have ?

Thx !

bbadrignans commented 3 years ago

It's a freebox delta on my side. Not sure the issue came out after homeassistant update, or after freebox automatic update It worked fine few weeks ago

benjR commented 3 years ago

Hi! Also a Delta on my side

gvigroux commented 3 years ago

Same problem on my Freebox Delta

SNoof85 commented 3 years ago

maybe something has changed on API side but as we are using fixed API version in the integration it should not happen. As I don't have anymore freebox at home, it's hard to help. @Quentame any idea ?

It would be nice if some of you can test outside of HA with the 0.0.8 version of the freebox-api lib that can be found here : https://github.com/hacf-fr/freebox-api/releases/tag/0.0.8

Download the 0.0.8 version with the link. Extract files Create a file sensor.py in same level than example.py and set correct host (api_domain) and port inside :

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'''
This example can be run safely as it won't change anything in your box configuration
'''

import asyncio
from aiofreepybox import Freepybox

async def demo():
    fbx = Freepybox()

    # To find out the HTTPS host and port of your freebox, go to
    # http://mafreebox.freebox.fr/api_version

    # Connect to the freebox
    # Be ready to authorize the application on the Freebox if you use this
    # example for the first time
    await fbx.open(host='abcdefgh.fbxos.fr', port=1234)

    fbx_config = await fbx.system.get_config()
    print(fbx_config)
    await fbx.close()

loop = asyncio.get_event_loop()
loop.run_until_complete(demo())
loop.close()

Then run this python script and post output here.

gvigroux commented 3 years ago

I've downloaded the latest lib version 0.9 and I add to correct the "from" line with: from freebox_api import Freepybox

{'temp_hdd0': 53, 'temp_sw': 49, 'user_main_storage': 'Freebox', 'temp_cpu_cp_slave': 83, 'mac': '.........', 'temp_cpu_cp_master': 84, 'box_flavor': 'light', 'fan_rpm': 1603, 'temp_cpu_ap': 69, 'disk_status': 'active', 'temp_cpum': 53, 'temp_cpub': 54, 'uptime': '33 jours 3 heures 46 minutes 46 secondes', 'uptime_val': ........., 'board_name': '....', 'box_authenticated': True, 'serial': '...........', 'firmware_version': '4.2.7'}

gvigroux commented 3 years ago

I've tested with the 0.8 lib above and I was able to run the script whitout any change. I got the same working output as my previous post

SNoof85 commented 3 years ago

Ok. I'll have a look to this ! Thanks for your help.

gvigroux commented 3 years ago

Don't hesitate to ask me for some tests. Can you explain me where I can find the python script on Github? I can check as well

gvigroux commented 3 years ago

The Freebox has received an update yesterday and it's working again!

SNoof85 commented 3 years ago

Hey good, i did not had time to have a look ;) Could you just out of curiosity make the same call with 0.8 version of the lib ?

gvigroux commented 3 years ago

Forget what I said: I've installed HA on another machine and I have the same issue again. With the lib 0.8 the output is the same as before:

{'temp_hdd0': 53, 'temp_sw': 49, 'user_main_storage': 'Freebox', 'temp_cpu_cp_slave': 83, 'mac': '.........', 'temp_cpu_cp_master': 84, 'box_flavor': 'light', 'fan_rpm': 1603, 'temp_cpu_ap': 69, 'disk_status': 'active', 'temp_cpum': 53, 'temp_cpub': 54, 'uptime': '33 jours 3 heures 46 minutes 46 secondes', 'uptime_val': ........., 'board_name': '....', 'box_authenticated': True, 'serial': '...........', 'firmware_version': '4.2.7'}

gvigroux commented 3 years ago

I found the problem in the code. When you add a HDD inside the Freebox, sometime you don't have the temperature value so sensor create fails. The solution is to replace in router.py (line 122)

        for sensor in syst_datas["sensors"]:
             self.sensors_temperature[sensor["name"]] = sensor["value"]

by

        for sensor in syst_datas["sensors"]:
            if "value" in sensor:
                self.sensors_temperature[sensor["name"]] = sensor["value"]

After everything works. But I have another question, it seems this integration just focus on device detection and do not create cover and switch managed by the freebox... I will check on how to add them

gvigroux commented 3 years ago

I have implemented a fix in the freebox/home branch. It will be integrated soon

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

bbadrignans-seclab commented 3 years ago

Hi, The issue is still there. It seems the fix is not integrated in the last release. Regards

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.