UNIFI import plugin 0.2

This commit is contained in:
Jokob-sk
2023-04-01 22:11:14 +11:00
parent 310b6de2cc
commit c8fcf6227e
2 changed files with 5 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
## Overview ## Overview
A plugin allowing for importing devices from an UniFi controller. A plugin allowing for importing devices from a UniFi controller.
### Usage ### Usage

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# Based on the work of https://github.com/stevehoek/Pi.Alert # Inspired by https://github.com/stevehoek/Pi.Alert
# Example call # Example call
# python3 /home/pi/pialert/front/plugins/unifi_import/script.py username=pialert password=passw0rd host=192.168.1.1 site=default protocol=https:// port=8443 # python3 /home/pi/pialert/front/plugins/unifi_import/script.py username=pialert password=passw0rd host=192.168.1.1 site=default protocol=https:// port=8443
@@ -19,7 +19,6 @@ import sys
from requests.packages.urllib3.exceptions import InsecureRequestWarning from requests.packages.urllib3.exceptions import InsecureRequestWarning
import pwd import pwd
import os import os
from unificontrol import UnifiClient
from pyunifi.controller import Controller from pyunifi.controller import Controller
@@ -110,7 +109,7 @@ def get_entries(newEntries):
tmpPlugObj = plugin_object_class( tmpPlugObj = plugin_object_class(
ap['mac'], ap['mac'],
ap['ip'], get_unifi_val(ap, 'ip'),
name, name,
'Ubiquiti Networks Inc.', 'Ubiquiti Networks Inc.',
deviceType, deviceType,
@@ -134,7 +133,7 @@ def get_entries(newEntries):
tmpPlugObj = plugin_object_class( tmpPlugObj = plugin_object_class(
cl['mac'], cl['mac'],
cl['ip'], get_unifi_val(cl, 'ip'),
name, name,
get_unifi_val(cl, 'oui'), get_unifi_val(cl, 'oui'),
'Other', 'Other',
@@ -156,7 +155,7 @@ def get_entries(newEntries):
tmpPlugObj = plugin_object_class( tmpPlugObj = plugin_object_class(
us['mac'], us['mac'],
us['ip'], get_unifi_val(us, 'ip'),
name, name,
get_unifi_val(us, 'oui'), get_unifi_val(us, 'oui'),
'Other', 'Other',