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
69.72k stars 28.88k forks source link

Fritzbox Integration displaying wrong values #107667

Open coro1404 opened 5 months ago

coro1404 commented 5 months ago

The problem

Fritzbox integration with fixed Internet speed is incorrectly reporting Speed in kb/s instead ob MBit/s (300 Mbit/s should display as Mbit or 300000 kbit/s) See "Link-Download/Upload" on attached Screenshots. Screenshot 2024-01-09 17 53 29 Screenshot 2024-01-09 17 56 30

What version of Home Assistant Core has the issue?

core-2023.12.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

fritzbox

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 5 months ago

Hey there @mammuth, @aarondavidschneider, @chemelli74, @mib1185, mind taking a look at this issue as it has been labeled with an integration (fritz) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `fritz` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign fritz` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


fritz documentation fritz source (message by IssueLinks)

chemelli74 commented 5 months ago

Please add the following to configuration.yaml , restart HA, and post the log:

logger:
  default: warning
  logs:
    homeassistant.components.fritz: debug
    fritzconnection: info

Note: it is better to drag the log into the comment (which will add it as an attachment) and not copy paste as it is hard to read logs in GitHub.

And add diagnostics (menu configuration -> integration -> fritz tools -> download diagnostics )

coro1404 commented 5 months ago

This is probably the problem: 2024-01-10 12:13:18.832 DEBUG (MainThread) [homeassistant.components.fritz.common] enity_data: {'call_deflections': {}, 'entity_states': {'external_ip': '192.168.2.2', 'external_ipv6': '::', 'device_uptime': datetime.datetime(2023, 10, 4, 13, 39, 57, 168745, tzinfo=datetime.timezone.utc), 'connection_uptime': datetime.datetime(2024, 1, 2, 10, 57, 13, 192620, tzinfo=datetime.timezone.utc), 'kb_s_sent': 100.5, 'kb_s_received': 3506.7, 'max_kb_s_sent': 50000.0, 'max_kb_s_received': 300000.0, 'gb_sent': 300.9, 'gb_received': 2093.1, 'link_kb_s_sent': 50.0, 'link_kb_s_received': 300.0, 'is_connected': True, 'is_linked': True}}

I'll attach the other logs as well - regards config_entry-fritz-748b615e50f297f9a7d06d6ac4e00ce6.json.txt home-assistant.log

mib1185 commented 5 months ago

yeah, this is a known bug in the API of the Fritz!Box itself, that it returns the wrong values. Unfortunately, there is nothing we could do from HA side nor the fritzconnection library itself. But feel free to report this to AVM (would be highly appreciated, since as more such reports reach AVM, it is likely more possible to be fixed by AVM)

ixs commented 5 months ago

I experienced the same problem and did a bit of digging. This does not look like a known bug in the API if the Fritz!Box itself.

I'm running Home-Assistant core 2024.1.2 inside a Docker container to make things easy to follow along at home.

As the docker container has kbr/fritzconnection embedded, we can use the packages cli interface to check what fritzconnection knows about the Fritz!Box and it's Uplink/Downlink State.

$ sudo docker-compose run homeassistant /usr/local/bin/fritzstatus

fritzconnection v1.13.2
FRITZ!Box 7490 at http://169.254.1.1
FRITZ!OS: 7.57

FritzStatus:

    is linked             : True
    is connected          : True
    external ip (v4)      : 127.10.11.12
    external ip (v6)      : c0ff:ee::babe
    internal ipv6-prefix  : c0ff:ee::babe
    uptime                : 08:44:15
    bytes send            : 2215597133
    bytes received        : 21375722054
    max. bit rate         : ('400.0 MBit/s', '400.0 MBit/s')

This looks good and matches reality. 400MBps links configured in Fritz!OS and also visible to the fritzconnection library.

So no, this does not look like bad values being returned by the Fritz!Box or the Library being unable to do anything about this problem.

Going to have another look later and come with a PR that fixes things.

mib1185 commented 5 months ago

in HA we use the same values returned by the fritzconnection lib in status.max_bit_rate (which is in bit/s), devide them by 1000 and show it as kBit/s in HA - see https://github.com/home-assistant/core/blob/066a0ccc6d3d95a8b61087d2044f3a8b7244b780/homeassistant/components/fritz/sensor.py#L87-L89

https://github.com/home-assistant/core/blob/066a0ccc6d3d95a8b61087d2044f3a8b7244b780/homeassistant/components/fritz/sensor.py#L92-L94

for any xDSL wan connection it is ok (the following is a screenshot from my system)

image

@ixs could you please provide the debug logging as mentioned in https://github.com/home-assistant/core/issues/107667#issuecomment-1884556156?

chemelli74 commented 5 months ago

$ sudo docker-compose run homeassistant /usr/local/bin/fritzstatus

fritzconnection v1.13.2 FRITZ!Box 7490 at http://169.254.1.1 FRITZ!OS: 7.57

FritzStatus:

is linked             : True
is connected          : True
external ip (v4)      : 127.10.11.12
external ip (v6)      : c0ff:ee::babe
internal ipv6-prefix  : c0ff:ee::babe
uptime                : 08:44:15
bytes send            : 2215597133
bytes received        : 21375722054
max. bit rate         : ('400.0 MBit/s', '400.0 MBit/s')


This looks good and matches reality. 400MBps links configured in Fritz!OS and also visible to the `fritzconnection` library.

Can you show us the values reported in HA log ?

DerGuenni commented 4 months ago

Problem also existing on a Fritz!Fiber 5590 connection with fixed speeds set via the ISP. When reading through the comments I couldn't quite figure out if this is a problem on AVMs side or with the integration? grafik grafik

mib1185 commented 4 months ago

if you have access to a python environment, than please perform the following commands and provide the full outputs _please replace FRITZBOX_IP FRITZBOX_USER and FRITZBOX_PASSWORD according your environment and don't paste these afterwards here_

pip install fritzconnection[qr]==1.13.2

fritzstatus -i <FRITZBOX_IP> -u <FRITZBOX_USER> -p <FRITZBOX_PASSWORD>

further please provide debug log and diagnostics data as mentioned in https://github.com/home-assistant/core/issues/107667#issuecomment-1884556156

DerGuenni commented 4 months ago

config_entry-fritz-48cb87556d6a50303a8d358ede3ba013.json home-assistant_fritz_2024-02-15T21-15-26.550Z.log

fritzconnection v1.13.2
FRITZ!Box 5590 Fiber at http://192.168.178.1
FRITZ!OS: 7.80

FritzStatus:

    is linked             : True
    is connected          : True
    external ip (v4)      : **REDACTED**
    external ip (v6)      : **REDACTED**
    internal ipv6-prefix  : **REDACTED**
    uptime                : 399:26:14
    bytes send            : 219611222219
    bytes received        : 167256385860
    max. bit rate         : ('1.0 GBit/s', '1.0 GBit/s')
chemelli74 commented 4 months ago
max. bit rate         : ('1.0 GBit/s', '1.0 GBit/s')

unfortunately the library doesn't show the correct value ( GBit/s vs Gbit/s ).

mib1185 commented 4 months ago

@DerGuenni

your log shows, that the correct values are used (they are in kbit/s)

'max_kb_s_sent': 1000000.0, 'max_kb_s_received': 1000000.0

what does the "Max connection download throughput" (Link-Download-Durchsatz) and "Max connection upload throughput" (Link-Upload-Durchsatz) shows?

DerGuenni commented 4 months ago

@mib1185

what does the "Max connection download throughput" (Link-Download-Durchsatz) and "Max connection upload throughput" (Link-Upload-Durchsatz) shows?

It says 1.000,0 kbit/s. Also, if I look at the current throughput it shows the correct values in kb/s. But from my understanding the 1.000 kbit/s are equaling 1 Mbit/s and are therefore wrong - or am I mistaken here?

grafik

mib1185 commented 4 months ago

mehhh ... i don't understand why 🤨 please provide screen shots of their states from "Developer tools -> States" - should look like

image

do you also have the "maximum connection throughput" sensors? (like in my screenshot)

chemelli74 commented 4 months ago

You are mixing "b" with "B", they are not the same unit

DerGuenni commented 4 months ago

grafik

You are mixing "b" with "B", they are not the same unit

Could you please explain? I know the difference between Kbit/s, Kibit/s and kB/s, but not KBit/s

mib1185 commented 4 months ago

image

these are the correct ones ... at least the show the correct values. need to check what is the purpose of the other sensors

DerGuenni commented 4 months ago

Ok thank you, I've updated my cards. I guess the default card that's being created when first setting up Home Assistant is using the wrong sensors then? Or is this a xDSL vs. all other connection types problem?

issue-triage-workflows[bot] commented 1 month 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.

ixs commented 1 month ago

Problem still persists, see https://github.com/home-assistant/core/issues/117177 (albeit incorrectly closed as completed)