kbr / fritzconnection

Python-Tool to communicate with the AVM Fritz!Box by the TR-064 protocol and the AHA-HTTP-Interface
MIT License
303 stars 59 forks source link

Cannot read connection speed from LAN device #207

Closed LutzFassl closed 5 months ago

LutzFassl commented 5 months ago

Hello & thanks for the awesome library.

My goal is to read the connection speed of my PC from the fritzbox using fritzconnection.

**Motivation / Background**

Due to a loose hardware connection of my PC my connection might drop from 1gbit to 100mbit or 10 mbit (does not disconnect entirely, which would be easy to detect). And I cannot detect it easily from my windows machine directly because there is another switch between my PC and the fritzbox. Therefore it seems to be logical to me to read the connection that the fritzbox displays for my PC. What I have tried successfully. I have used both the CLI and also the python library to run multiple commands succesfully such as: ```python device_infos = fc.call_action('Hosts', 'GetSpecificHostEntry', arguments={'NewMACAddress': LUTZPCMAC}) ``` Result: {'NewIPAddress': '192.168.0.49', 'NewAddressSource': 'Static', 'NewLeaseTimeRemaining': 0, 'NewInterfaceType': 'Ethernet', 'NewActive': True, 'NewHostName': 'lutzPC22'}

Issue

However I need to get the connection speed. In the fritzbox web interface I can see it like this:

image

And there should also be the possibility to read it using TR-064 according to the documentation:

image

I try to read it like this:

device_infos = fc.call_action('Hosts', 'GetSpecificHostEntryByIp', arguments={'NewIPAddress': "192.168.0.49"})

However my result is always this: image

Is it possible that this command is just not implemented in fritzconnection or am I doing something wrong? Thanks!

LutzFassl commented 5 months ago

Nevermind, it just worked with the codeline. Before I tried with different action-strings such as 'X_AVM-DE_GetSpecificHostEntryByIP' and 'GetSpecificHostEntryByIP' but probably had a typo. I won't delete it so other people can find it to fix their typo too.

correct:

device_infos = fc.call_action('Hosts', 'X_AVM-DE_GetSpecificHostEntryByIP', arguments={'NewIPAddress': "192.168.0.49"})

{'NewMACAddress': 'xyz', 'NewActive': True, 'NewHostName': 'lutzPC22', 'NewInterfaceType': 'Ethernet', 'NewX_AVM-DE_Port': 2, 'NewX_AVM-DE_Speed': 1000, 'NewX_AVM-DE_UpdateAvailable': False, 'NewX_AVM-DE_UpdateSuccessful': 'unknown', 'NewX_AVM-DE_InfoURL': '', 'NewX_AVM-DE_MACAddressList': 'xyz', 'NewX_AVM-DE_Model': '', 'NewX_AVM-DE_URL': '', 'NewX_AVM-DE_Guest': False, 'NewX_AVM-DE_RequestClient': True, 'NewX_AVM-DE_VPN': False, 'NewX_AVM-DE_WANAccess': 'granted', 'NewX_AVM-DE_Disallow': False, 'NewX_AVM-DE_IsMeshable': False, 'NewX_AVM-DE_Priority': False, 'NewX_AVM-DE_FriendlyName': 'lutzPC22', 'NewX_AVM-DE_FriendlyNameIsWriteable': True}