{
    "code_name": "unifi_import",
    "show_ui": true,
    "unique_prefix": "UNFIMP",
    "plugin_type": "device_scanner",
    "data_source": "script",
    "localized": [
        "display_name",
        "description",
        "icon"
    ],
    "display_name": [
        {
            "language_code": "en_us",
            "string": "UniFi import"
        },
        {
            "language_code": "es_es",
            "string": "Importación UniFi"
        }
    ],
    "enabled": true,
    "mapped_to_table": "CurrentScan",    
    "icon": [
        {
            "language_code": "en_us",
            "string": "<i class=\"fa-solid fa-upload\"></i>"
        },
        {
            "language_code": "es_es",
            "string": "<i class=\"fa-solid fa-upload\"></i>"
        }
    ],    
    "params": [
        {
            "name": "username",
            "type": "setting",
            "value": "UNFIMP_username"
        },
        {
            "name": "password",
            "type": "setting",
            "value": "UNFIMP_password"
        },
        {
            "name": "host",
            "type": "setting",
            "value": "UNFIMP_host"
        },
        {
            "name": "sites",
            "type": "setting",
            "value": "UNFIMP_sites"
        },
        {
            "name": "port",
            "type": "setting",
            "value": "UNFIMP_port"
        },
        {
            "name": "verifyssl",
            "type": "setting",
            "value": "UNFIMP_verifyssl"
        },
        {
            "name": "version",
            "type": "setting",
            "value": "UNFIMP_version"
        },
        {	
            "name": "fullimport",
            "type": "setting",
            "value": "UNFIMP_fullimport"
        }
    ],
    "data_filters": [
        {
            "compare_column": "Object_PrimaryID",
            "compare_field_id": "txtMacFilter",
            "compare_js_template": "'{value}'.toString()",
            "compare_operator": "==",
            "compare_use_quotes": true
        }
    ],    
    "database_column_definitions": [
        {
            "column": "Index",
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "N/A"
                },
                {
                    "language_code": "es_es",
                    "string": "N/A"
                },
                {
                    "language_code": "de_de",
                    "string": "N/A"
                }
            ],
            "options": [],
            "show": false,
            "type": "label"
        },
        {
            "column": "Plugin",
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "N/A"
                },
                {
                    "language_code": "es_es",
                    "string": "N/A"
                },
                {
                    "language_code": "de_de",
                    "string": "N/A"
                }
            ],
            "options": [],
            "show": false,
            "type": "label"
        },
        {
            "column": "Object_PrimaryID",
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "mapped_to_column": "cur_MAC",
            "name": [
                {
                    "language_code": "en_us",
                    "string": "MAC address"
                },
                {
                    "language_code": "es_es",
                    "string": "Dirección MAC"
                },
                {
                    "language_code": "de_de",
                    "string": "MAC Adresse"
                }
            ],
            "options": [],
            "show": true,
            "type": "device_mac"
        },
        {
            "column": "Object_SecondaryID",
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "mapped_to_column": "cur_IP",
            "name": [
                {
                    "language_code": "en_us",
                    "string": "IP"
                },
                {
                    "language_code": "es_es",
                    "string": "IP"
                },
                {
                    "language_code": "de_de",
                    "string": "IP"
                }
            ],
            "options": [],
            "show": true,
            "type": "device_ip"
        },
        {
            "column": "DateTimeCreated",
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Created"
                },
                {
                    "language_code": "es_es",
                    "string": "Creado"
                },
                {
                    "language_code": "de_de",
                    "string": "Erstellt"
                }
            ],
            "options": [],
            "show": true,
            "type": "label"
        },
        {
            "column": "DateTimeChanged",
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "mapped_to_column": "cur_DateTime",
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Changed"
                },
                {
                    "language_code": "es_es",
                    "string": "Cambiado"
                },
                {
                    "language_code": "de_de",
                    "string": "Angepasst"
                }
            ],
            "options": [],
            "show": true,
            "type": "label"
        },
        {
            "column": "Watched_Value1",
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "mapped_to_column": "cur_Name",
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Hostname"
                },
                {
                    "language_code": "es_es",
                    "string": "Nombre de host"
                },
                {
                    "language_code": "de_de",
                    "string": "Name des Hosts"
                }
            ],
            "options": [],
            "show": true,
            "type": "label"
        },
        {
            "column": "Watched_Value2",
            "mapped_to_column": "cur_Vendor",  
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Vendor"
                },
                {
                    "language_code": "es_es",
                    "string": "Proveedor"
                },
                {
                    "language_code": "de_de",
                    "string": "Hersteller"
                }
            ],
            "options": [],
            "show": true,
            "type": "label"
        },
        {
            "column": "Watched_Value3",
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Type"
                },
                {
                    "language_code": "es_es",
                    "string": "Tipo"
                },
                {
                    "language_code": "de_de",
                    "string": "Typ"
                }
            ],
            "options": [],
            "show": true,
            "type": "label"
        },
        {
            "column": "Watched_Value4",
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Online?"
                },
                {
                    "language_code": "es_es",
                    "string": "¿Online?"
                },
                {
                    "language_code": "de_de",
                    "string": "Online?"
                }
            ],
            "options": [],
            "show": true,
            "type": "label"
        },
        {
            "column": "UserData",
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Comments"
                },
                {
                    "language_code": "es_es",
                    "string": "Comentarios"
                },
                {
                    "language_code": "de_de",
                    "string": "Kommentar"
                }
            ],
            "options": [],
            "show": false,
            "type": "textbox_save"
        },
        {
            "column": "Dummy",
            "css_classes": "col-sm-2",
            "default_value": "",
            "localized": [
                "name"
            ],
            "mapped_to_column": "cur_ScanMethod",
            "mapped_to_column_data": {
                "value": "UNFIMP"
            },
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Scan method"
                },
                {
                    "language_code": "es_es",
                    "string": "Método de escaneo"
                },
                {
                    "language_code": "de_de",
                    "string": "Scan Methode"
                }
            ],
            "options": [],
            "show": true,
            "type": "label"
        },
        {
            "column": "Extra",
            "css_classes": "col-sm-3",
            "default_value": "",
            "localized": [
                "name"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Network"
                },
                {
                    "language_code": "es_es",
                    "string": "Red"
                },
                {
                    "language_code": "de_de",
                    "string": "Netzwerk"
                }
            ],
            "options": [],
            "show": true,
            "type": "label"
        },
        {
            "column": "Status",
            "css_classes": "col-sm-1",
            "default_value": "",
            "localized": [
                "name"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Status"
                },
                {
                    "language_code": "es_es",
                    "string": "Estado"
                },
                {
                    "language_code": "de_de",
                    "string": "Status"
                }
            ],
            "options": [
                {
                    "equals": "watched-not-changed",
                    "replacement": "<div style='text-align:center'><i class='fa-solid fa-square-check'></i><div></div>"
                },
                {
                    "equals": "watched-changed",
                    "replacement": "<div style='text-align:center'><i class='fa-solid fa-triangle-exclamation'></i></div>"
                },
                {
                    "equals": "new",
                    "replacement": "<div style='text-align:center'><i class='fa-solid fa-circle-plus'></i></div>"
                },
                {
                    "equals": "missing-in-last-scan",
                    "replacement": "<div style='text-align:center'><i class='fa-solid fa-question'></i></div>"
                }
            ],
            "show": true,
            "type": "replace"
        }
    ],
    "description": [
        {
            "language_code": "en_us",
            "string": "This plugin is used to import devices from an UNIFI controller."
        },
        {
            "language_code": "es_es",
            "string": "Este plugin se utiliza para importar dispositivos desde un controlador UNIFI."
        },
        {
            "language_code": "de_de",
            "string": "Dieses Plugin imporiert die Geräte von einem UNIFI Controller."
        }
    ],    
    "settings": [
        {
            "default_value": "disabled",
            "description": [
                {
                    "language_code": "en_us",
                    "string": "Enable import of devices from a UNIFI controller. If you select <code>schedule</code> the scheduling settings from below are applied. If you select <code>once</code> the scan is run only once on start of the application (container) or after you update your settings. ⚠ Use the same schedule if you have multiple <i class=\"fa-solid fa-magnifying-glass-plus\"></i> Device scanners enabled."
                },
                {
                    "language_code": "es_es",
                    "string": "Habilite la importación de dispositivos desde un controlador UNIFI. Si selecciona <code>schedule</code>, se aplican las configuraciones de programación de abajo. Si selecciona <code>once</code>, el análisis se ejecuta solo una vez al iniciar la aplicación (contenedor) o después de actualizar su configuración."
                },
                {
                    "language_code": "de_de",
                    "string": "Aktiviere den Import von einem UNIFI controller. Bei <code>schedule</code> werden die Richtzeiten von weiter unten verwendet. Bei der Auswahl <code>once</code> der Import wird einmalig beim Start der Applikation (container), oder nach einem Update der Einstellungen durchgeführt."
                }
            ],
            "function": "RUN",
            "events": ["run"],
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "When to run"
                },
                {
                    "language_code": "es_es",
                    "string": "Cuándo ejecutar"
                },
                {
                    "language_code": "de_de",
                    "string": "Ausführungszeitpunkt"
                }
            ],
            "options": [
                "disabled",
                "once",
                "schedule",
                "always_after_scan",
                "on_new_device"
            ],
            "type": "text.select"
        },
        {
            "default_value": "python3 /app/front/plugins/unifi_import/script.py username={username} password={password}  host={host} sites={sites} port={port} verifyssl={verifyssl} version={version} fullimport={fullimport}",
            "description": [
                {
                    "language_code": "en_us",
                    "string": "Command to run. Not recommended to change."
                },
                {
                    "language_code": "es_es",
                    "string": "Comando para ejecutar. No se recomienda cambiar."
                },
                {
                    "language_code": "de_de",
                    "string": "Befehl der ausgeführt wird. Anpassung nicht empfohlen"
                }
            ],
            "function": "CMD",
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Command"
                },
                {
                    "language_code": "es_es",
                    "string": "Comando"
                },
                {
                    "language_code": "de_de",
                    "string": "Befehl"
                }
            ],
            "options": [],
            "type": "text"
        },
        {
            "default_value": "",
            "description": [
                {
                    "language_code": "en_us",
                    "string": "The username used to login into your UNIFI controller. It is recommended to create a read-only user account."
                },
                {
                    "language_code": "es_es",
                    "string": "El nombre de usuario utilizado para iniciar sesión en su controlador UNIFI. Se recomienda crear una cuenta de usuario de sólo lectura."
                }
            ],
            "function": "username",
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Username"
                },
                {
                    "language_code": "es_es",
                    "string": "Nombre de usuario"
                }
            ],
            "options": [],
            "type": "text"
        },
        {
            "default_value": "",
            "description": [
                {
                    "language_code": "en_us",
                    "string": "The password used to login into your UNIFI controller."
                },
                {
                    "language_code": "es_es",
                    "string": "La contraseña utilizada para iniciar sesión en su controlador UNIFI."
                }
            ],
            "function": "password",
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Password"
                },
                {
                    "language_code": "es_es",
                    "string": "Contraseña"
                }
            ],
            "options": [],
            "type": "password"
        },
        {
            "default_value": "192.168.1.1",
            "description": [
                {
                    "language_code": "en_us",
                    "string": "The host (IP) where the UNIFI controller is runnig. Do NOT include the protocol (e.g. <code>https://</code>)"
                },
                {
                    "language_code": "es_es",
                    "string": "El host (IP) donde se ejecuta el controlador UNIFI. NO incluya el protocolo (por ejemplo, <code>https://</code>)"
                }
            ],
            "function": "host",
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Host"
                },
                {
                    "language_code": "es_es",
                    "string": "Host"
                }
            ],
            "options": [],
            "type": "text"
        },
        {
            "default_value": "8443",
            "description": [
                {
                    "language_code": "en_us",
                    "string": "The port number where the UNIFI controller is runnig. Usually it is <code>8443</code>, for UDM(P) devices its 443."
                },
                {
                    "language_code": "es_es",
                    "string": "El número de puerto donde se ejecuta el controlador UNIFI. Normalmente es <code>8443</code>."
                }
            ],
            "function": "port",
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Port number"
                },
                {
                    "language_code": "es_es",
                    "string": "Número de puerto"
                }
            ],
            "options": [],
            "type": "text"
        },
        {
            "default_value": "false",
            "description": [
                {
                    "language_code": "en_us",
                    "string": "verify SSL certificate validity <code>true|false</code>."
                },
                {
                    "language_code": "es_es",
                    "string": "verificar la validez del certificado SSL <code>true|false</code>."
                }
            ],
            "function": "verifyssl",
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "verify SSL"
                },
                {
                    "language_code": "es_es",
                    "string": "verificar SSL"
                }
            ],
            "options": ["true", "false"],
            "type": "text.select"
        },
        {
            "function": "version",
            "type": "text",
            "default_value": "v4",
            "options": [],
            "localized": ["name","description"],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "API version"
                },
                {
                    "language_code": "es_es",
                    "string": "Versión API"
                }
            ],
	    "description": [
                {
                    "language_code": "en_us",
                    "string": "The base version of the Unify controller API. Supported values as of time of writing are <code>v4|v5|unifiOS|UDMP-unifiOS</code>."
                },
                {
                    "language_code": "es_es",
                    "string": "La versión base de la API del controlador Unify. Los valores admitidos al momento de escribir este artículo son <code>v4|v5|unifiOS|UDMP-unifiOS</code>."
                }
            ]
            
        },
        {
            "default_value": [
                "default"
            ],
            "description": [
                {
                    "language_code": "en_us",
                    "string": "The sites you want to connect to. Usually it is only one and the name is <code>default</code>. Check the URL in your UniFi controller UI if unsure."
                },
                {
                    "language_code": "es_es",
                    "string": "Los sitios a los que desea conectarse. Generalmente es solo uno y el nombre es <code>default</code>. Verifique la URL en la interfaz de usuario de su controlador UniFi si no está seguro."
                }
            ],
            "function": "sites",
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "UNIFI sites"
                },
                {
                    "language_code": "es_es",
                    "string": "Sitios UNIFI"
                }
            ],
            "options": [],
            "type": "list"
        },
        {
            "default_value": "0 2 * * *",
            "description": [
                {
                    "language_code": "en_us",
                    "string": "Only enabled if you select <code>schedule</code> in the <a href=\"#UNFIMP_RUN\"><code>UNFIMP_RUN</code> setting</a>. Make sure you enter the schedule in the correct cron-like format (e.g. validate at <a href=\"https://crontab.guru/\" target=\"_blank\">crontab.guru</a>). For example entering <code>0 4 * * *</code> will run the scan after 4 am in the <a onclick=\"toggleAllSettings()\" href=\"#TIMEZONE\"><code>TIMEZONE</code> you set above</a>. Will be run NEXT time the time passes. <br/> It's recommended to use the same schedule interval for all plugins responsible for discovering new devices. "
                },
                {
                    "language_code": "es_es",
                    "string": "Solo está habilitado si selecciona <code>schedule</code> en la configuración <a href=\"#UNFIMP_RUN\"><code>UNFIMP_RUN</code></a>. Asegúrese de ingresar la programación en el formato similar a cron correcto (por ejemplo, valide en <a href=\"https://crontab.guru/\" target=\"_blank\">crontab.guru</a>). Por ejemplo, ingresar <code>0 4 * * *</code> ejecutará el escaneo después de las 4 a.m. en el <a onclick=\"toggleAllSettings()\" href=\"#TIMEZONE\"><code>TIMEZONE</ código> que configuró arriba</a>. Se ejecutará la PRÓXIMA vez que pase el tiempo."
                }
            ],
            "function": "RUN_SCHD",
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Schedule"
                },
                {
                    "language_code": "es_es",
                    "string": "Schedule"
                }
            ],
            "options": [],
            "type": "text"
        },
        {
            "default_value": 5,
            "description": [
                {
                    "language_code": "en_us",
                    "string": "Maximum time in seconds to wait for the script to finish. If this time is exceeded the script is aborted."
                },
                {
                    "language_code": "es_es",
                    "string": "Tiempo máximo en segundos para esperar a que finalice el script. Si se supera este tiempo, el script se cancela."
                },
                {
                    "language_code": "de_de",
                    "string": "Maximale Laufzeit des Scripts. Nach Ablauf der Zeit wird das Script abgebrochen."
                }
            ],
            "function": "RUN_TIMEOUT",
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Run timeout"
                },
                {
                    "language_code": "es_es",
                    "string": "Tiempo límite de ejecución"
                },
                {
                    "language_code": "de_de",
                    "string": "Wartezeit"
                }
            ],
            "options": [],
            "type": "integer"
        },
        {
            "default_value": [
                "Watched_Value1",
                "Watched_Value4"
            ],
            "description": [
                {
                    "language_code": "en_us",
                    "string": "Send a notification if selected values change. Use <code>CTRL + Click</code> to select/deselect. <ul> <li><code>Watched_Value1</code> is Hostname </li><li><code>Watched_Value2</code> is Vendor </li><li><code>Watched_Value3</code> is Type </li><li><code>Watched_Value4</code> is Online </li></ul>"
                },
                {
                    "language_code": "es_es",
                    "string": "Envíe una notificación si los valores seleccionados cambian. Utilice <code>CTRL + clic</code> para seleccionar/deseleccionar. <ul> <li><code>Watched_Value1</code> es el nombre de host </li><li><code>Watched_Value2</code> es el proveedor </li><li><code>Watched_Value3</code> es el tipo </li><li><code>Watched_Value4</code> es Online </li></ul>"
                }
            ],
            "function": "WATCH",
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Watched"
                },
                {
                    "language_code": "es_es",
                    "string": "Visto"
                }
            ],
            "options": [
                "Watched_Value1",
                "Watched_Value2",
                "Watched_Value3",
                "Watched_Value4"
            ],
            "type": "text.multiselect"
        },
        {
            "default_value": [
                "new",
                "watched-changed"
            ],
            "description": [
                {
                    "language_code": "en_us",
                    "string": "Send a notification only on these statuses. <code>new</code> means a new unique (unique combination of PrimaryId and SecondaryId) object was discovered. <code>watched-changed</code> means that selected <code>Watched_ValueN</code> columns changed."
                },
                {
                    "language_code": "es_es",
                    "string": "Envíe una notificación solo en estos estados. <code>new</code> significa que se descubrió un nuevo objeto único (una combinación única de PrimaryId y SecondaryId). <code>watched-changed</code> significa que las columnas <code>Watched_ValueN</code> seleccionadas cambiaron."
                }
            ],
            "function": "REPORT_ON",
            "localized": [
                "name",
                "description"
            ],
            "name": [
                {
                    "language_code": "en_us",
                    "string": "Report on"
                },
                {
                    "language_code": "es_es",
                    "string": "Informar sobre"
                }
            ],
            "options": [
                "new",
                "watched-changed",
                "watched-not-changed",
                "missing-in-last-scan"
            ],
            "type": "text.multiselect"
        },
        {
        "default_value": "disabled",
        "description": [
            {
                "language_code": "en_us",
                "string": "Enable a full import of all known devices by the controller instead of only the online ones. During the scan, all found devices appear online. If you select <code>once</code> the full import is only performed once and the status is set to <code>done</code> afterwards."
            },
            {
                "language_code": "es_es",
                "string": "Translation Needed - Enable a full import of all known devices by the controller instead of only the online ones. During the scan, all found devices appear online. If you select <code>once</code> the full import is only performed once and the status is set to <code>done</code> afterwards."
            },
            {
                "language_code": "de_de",
                "string": "Führe einen kompletten Import aller dem Controller bekannten Geräten durch. Während des Scans werden alle gefundenen Geräte einmalig als Online angezeigt. Bei der Auswahl von <code>once</code> wird der Scan einmalig durchgeführt und der Status anschliessend auf <code>done</code> gesetzt"
            }
        ],
        "function": "fullimport",
        "localized": [
            "name",
            "description"
        ],
        "name": [
            {
                "language_code": "en_us",
                "string": "Perform full import"
            },
            {
                "language_code": "es_es",
                "string": "[ES] Perform full import"
            },
            {
                "language_code": "de_de",
                "string": "Vollständigen Import durchführen"
            }
        ],
        "options": [
            "disabled",
            "once",
            "always"
        ],
        "type": "text.select"
        }
    ]    
}
