From f6239154a47d3fdfac9c60c946df94f5e09fafae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20J=C3=BCtte?= Date: Sun, 25 Oct 2020 01:09:15 +0200 Subject: [PATCH 1/2] Add get_host_name method Add get_host_name method for easy access of the device name. --- fritzconnection/lib/fritzhosts.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fritzconnection/lib/fritzhosts.py b/fritzconnection/lib/fritzhosts.py index e08635a..119859d 100644 --- a/fritzconnection/lib/fritzhosts.py +++ b/fritzconnection/lib/fritzhosts.py @@ -148,6 +148,19 @@ def set_host_name(self, mac_address, name): } self._action('X_AVM-DE_SetHostNameByMACAddress', arguments=args) + def get_host_name(self, mac_address): + """ + Returns a String with the host_name of the device with the given mac_address + """ + host = list + try: + host = self.get_specific_host_entry(mac_address) + except: + host = { + 'NewHostName': 'Error' # fix this problem --> if the router mac is transferd i got an error with specific host entry method + } + return host['NewHostName'] + def run_host_update(self, mac_address): """ Triggers the host with the given `mac_address` to run a system From 6bd3e271405b2324f4e857b8afc5dc700e475b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20J=C3=BCtte?= Date: Tue, 27 Oct 2020 12:26:43 +0100 Subject: [PATCH 2/2] shortend get_host_name Changed to fit request for original repo --- fritzconnection/lib/fritzhosts.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/fritzconnection/lib/fritzhosts.py b/fritzconnection/lib/fritzhosts.py index 119859d..d47a1c6 100644 --- a/fritzconnection/lib/fritzhosts.py +++ b/fritzconnection/lib/fritzhosts.py @@ -152,14 +152,7 @@ def get_host_name(self, mac_address): """ Returns a String with the host_name of the device with the given mac_address """ - host = list - try: - host = self.get_specific_host_entry(mac_address) - except: - host = { - 'NewHostName': 'Error' # fix this problem --> if the router mac is transferd i got an error with specific host entry method - } - return host['NewHostName'] + return self.get_specific_host_entry(mac_address)['NewHostName'] def run_host_update(self, mac_address): """