mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Normalizing device names #833
This commit is contained in:
@@ -21,7 +21,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
|
|||||||
|
|
||||||
from plugin_helper import Plugin_Object, Plugin_Objects, rmBadChars, is_typical_router_ip
|
from plugin_helper import Plugin_Object, Plugin_Objects, rmBadChars, is_typical_router_ip
|
||||||
from logger import mylog
|
from logger import mylog
|
||||||
from helper import timeNowTZ, get_setting_value
|
from helper import timeNowTZ, get_setting_value, normalize_string
|
||||||
import conf
|
import conf
|
||||||
from pytz import timezone
|
from pytz import timezone
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ def collect_details(device_type, devices, online_macs, processed_macs, plugin_ob
|
|||||||
for device in devices:
|
for device in devices:
|
||||||
mylog('verbose', [f'{json.dumps(device)}'])
|
mylog('verbose', [f'{json.dumps(device)}'])
|
||||||
|
|
||||||
# try extracting variables from teh json
|
# try extracting variables from the json
|
||||||
name = get_name(get_unifi_val(device, 'name'), get_unifi_val(device, 'hostname'))
|
name = get_name(get_unifi_val(device, 'name'), get_unifi_val(device, 'hostname'))
|
||||||
ipTmp = get_ip(get_unifi_val(device, 'lan_ip'), get_unifi_val(device, 'last_ip'), get_unifi_val(device, 'fixed_ip'), get_unifi_val(device, 'ip'))
|
ipTmp = get_ip(get_unifi_val(device, 'lan_ip'), get_unifi_val(device, 'last_ip'), get_unifi_val(device, 'fixed_ip'), get_unifi_val(device, 'ip'))
|
||||||
macTmp = device['mac']
|
macTmp = device['mac']
|
||||||
@@ -178,7 +178,7 @@ def collect_details(device_type, devices, online_macs, processed_macs, plugin_ob
|
|||||||
plugin_objects.add_object(
|
plugin_objects.add_object(
|
||||||
primaryId=macTmp,
|
primaryId=macTmp,
|
||||||
secondaryId=ipTmp,
|
secondaryId=ipTmp,
|
||||||
watched1=name,
|
watched1=normalize_string(name),
|
||||||
watched2=get_unifi_val(device, 'oui', device_vendor),
|
watched2=get_unifi_val(device, 'oui', device_vendor),
|
||||||
watched3=deviceType,
|
watched3=deviceType,
|
||||||
watched4=status,
|
watched4=status,
|
||||||
|
|||||||
Reference in New Issue
Block a user