From b28165200922945c9f0a6c01f2feef0e7cd4143b Mon Sep 17 00:00:00 2001 From: stefan-linux Date: Wed, 30 Aug 2023 13:18:53 +0200 Subject: [PATCH] changed unifi_import to only export online devices --- front/plugins/unifi_import/script.py | 32 +++++++++++----------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/front/plugins/unifi_import/script.py b/front/plugins/unifi_import/script.py index e4917067..e10b68c5 100755 --- a/front/plugins/unifi_import/script.py +++ b/front/plugins/unifi_import/script.py @@ -129,8 +129,7 @@ def get_entries(newEntries): name = get_unifi_val(ap, 'name') hostName = get_unifi_val(ap, 'hostname') - if name == 'null' and hostName != 'null': - name = hostName + name = set_name(name, hostName) tmpPlugObj = plugin_object_class( ap['mac'], @@ -153,13 +152,6 @@ def get_entries(newEntries): for cl in c.get_clients(): # print(f'{json.dumps(cl)}') - - name = get_unifi_val(cl, 'name') - hostName = get_unifi_val(cl, 'hostname') - - if name == 'null' and hostName != 'null': - name = hostName - online_macs.add(cl['mac']) unifi_logger.debug(f'Found {len(online_macs)} Online Clients') @@ -178,17 +170,19 @@ def get_entries(newEntries): status = 1 if user['mac'] in online_macs else 0 - tmpPlugObj = plugin_object_class( - user['mac'], - get_unifi_val(user, 'last_ip'), - name, - get_unifi_val(user, 'oui'), - 'Other', - status, - get_unifi_val(user, 'last_connection_network_name') - ) + if status == 1: - newEntries.append(tmpPlugObj) + tmpPlugObj = plugin_object_class( + user['mac'], + get_unifi_val(user, 'last_ip'), + name, + get_unifi_val(user, 'oui'), + 'Other', + status, + get_unifi_val(user, 'last_connection_network_name') + ) + + newEntries.append(tmpPlugObj) unifi_logger.debug(f'Found {len(newEntries)} Clients overall') return newEntries