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

Add get_host_name method #75

Closed marvinjuette closed 3 years ago

marvinjuette commented 3 years ago

Add get_host_name method for easy access of the device name.

Known Issues: Sometimes get_specifiy_host_entry returns nothing and host is empty, but this occurred only when the repeaters mac was checked. But I already created an issue ( #74 ) because of some problems with repeaters.

kbr commented 3 years ago

@marvinjuette you can boild down the code to

def get_host_name(self, mac_address):
    return self.get_specific_host_entry(mac_address)['NewHostName']

and leave the error-handling to the caller, who can decide what to do. Does this code return meaningfull devicenames where the other service get_generic_host_entry just returns generic names? I've not tested this so far.

marvinjuette commented 3 years ago

@kbr I created this method because generic_host_entry uses the index of the host in order to display all the data. And I want to get the hostname just from a mac.

marvinjuette commented 3 years ago

@kbr updated my code.