kbr / fritzconnection

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

get_hosts_info() with 5GHz WLAN Devices #72

Closed ObiWanLansi closed 3 years ago

ObiWanLansi commented 3 years ago

Hi everybody,

i've a problem with the get_hosts_info() function from FritzWLAN, this function only returns the 2.4 GHz devices, but not the 5GHz devices.

But the function get_hosts_info() from FritzHosts return all WLan devices (but without some properties like signal and speed).

Have somebody else the same issue or an solution ?

Thnx, ObiWanLansi

kbr commented 3 years ago

As the method names are the same, FritzWLAN inspects the active devices for a single service (2.4 GHz, 5 GHz or the guest network). FritzHosts instead inspects all known devices, regardless whether they are active or inactive or connected by LAN or WLAN. Therefore you get different informations.

To get the host informations from all active devices connected via WLAN, FritzWLAN has to iterate over the services, i.e.:

from itertools import count

import fritzconnection
from fritzconnection.core.exceptions import FritzServiceError
from fritzconnection.lib.fritzwlan import FritzWLAN

fc = fritzconnection.FritzConnection(address='x.x.x.x', password='the_password')

for service in count(1):
    # example to reuse fc once it's instanciated:  
    fw = FritzWLAN(fc, service=service)
    try:
        print(fw.get_hosts_info())
    except FritzServiceError:
        break
ObiWanLansi commented 3 years ago

Ahhh, i belive i understand now, the Network is an parameter at FritzWLAN, and 2.4GHz is the default value, so it works for me fine. But when i want to have also the 5GHz devices, i muss add this parameter. I'll try again :-) .

Thnx