{
  "code_name": "adguard_import",
  "unique_prefix": "ADGUARDIMP",
  "plugin_type": "device_scanner",
  "execution_order" : "Layer_0",
  "enabled": true,
  "data_source": "script",
  "mapped_to_table": "CurrentScan",
  "data_filters": [
    {
      "compare_column": "Object_PrimaryID",
      "compare_operator": "==",
      "compare_field_id": "txtMacFilter",
      "compare_js_template": "'{value}'.toString()",
      "compare_use_quotes": true
    }
  ],
  "show_ui": true,
  "localized": ["display_name", "description", "icon"],
  "display_name": [
    {
      "language_code": "en_us",
      "string": "AdGuard (Device import)"
    }
  ],
  "description": [
    {
      "language_code": "en_us",
      "string": "Plugin to ..."
    }
  ],
  "icon": [
    {
      "language_code": "en_us",
      "string": "<i class=\"fa fa-search\"></i>"
    }
  ],
  "params": [],
   "settings": [
    {
      "function": "RUN",
      "events": ["run"],
      "type": {
        "dataType": "string",
        "elements": [
          { "elementType": "select", "elementOptions": [], "transformers": [] }
        ]
      },

      "default_value": "disabled",
      "options": [
        "disabled",
        "before_name_updates",
        "on_new_device",
        "once",
        "schedule",
        "always_after_scan"
      ],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "When to run"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "When the plugin should run. A good option is <code>schedule</code> for device scanners."
        }
      ]
    },
    {
      "function": "RUN_SCHD",
      "type": {
        "dataType": "string",
        "elements": [
          {
            "elementType": "span",
            "elementOptions": [
              {
                "cssClasses": "input-group-addon validityCheck"
              },
              {
                "getStringKey": "Gen_ValidIcon"
              }
            ],
            "transformers": []
          },
          {
            "elementType": "input",
            "elementOptions": [
              {
                "focusout": "validateRegex(this)"
              },
              {
                "base64Regex": "Xig/OlwqfCg/OlswLTldfFsxLTVdWzAtOV18WzAtOV0rLVswLTldK3xcKi9bMC05XSspKVxzKyg/OlwqfCg/OlswLTldfDFbMC05XXwyWzAtM118WzAtOV0rLVswLTldK3xcKi9bMC05XSspKVxzKyg/OlwqfCg/OlsxLTldfFsxMl1bMC05XXwzWzAxXXxbMC05XSstWzAtOV0rfFwqL1swLTldKykpXHMrKD86XCp8KD86WzEtOV18MVswLTJdfFswLTldKy1bMC05XSt8XCovWzAtOV0rKSlccysoPzpcKnwoPzpbMC02XXxbMC02XS1bMC02XXxcKi9bMC05XSspKSQ="
              }
            ],
            "transformers": []
          }
        ]
      },
      "default_value": "*/5 * * * *",
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Schedule"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Only enabled if you select <code>schedule</code> in the <a href=\"#SYNC_RUN\"><code>SYNC_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."
        }
      ]
    },
    {
      "function": "CMD",
      "type": {
        "dataType": "string",
        "elements": [
          {
            "elementType": "input",
            "elementOptions": [{ "readonly": "true" }],
            "transformers": []
          }
        ]
      },
      "default_value": "python3 /app/front/plugins/adguard_import/adguard_import.py",
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Command"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Command to run. This can not be changed"
        }
      ]
    },
    {
      "function": "RUN_TIMEOUT",
      "type": {
        "dataType": "integer",
        "elements": [
          {
            "elementType": "input",
            "elementOptions": [{ "type": "number" }],
            "transformers": []
          }
        ]
      },
      "default_value": 30,
      "options": [],
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Run timeout"
        }
      ],
      "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."
        }
      ]
    },
    {
      "function": "SERVER",
      "type": {
        "dataType": "string",
        "elements": [
          { "elementType": "input", "elementOptions": [], "transformers": [] }
        ]
      },
      "maxLength": 200,
      "default_value": "",
      "localized": ["name", "description"],
      "name": [
        {
          "language_code": "en_us",
          "string": "AdGuard Home Server"
        }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Hostname or IP of your AdGuard Home server. <br>Example: <code>192.168.1.10</code> or <code>adguard.local</code>"
        }
      ]
    },
    {
      "function": "PORT",
      "type": {
        "dataType": "integer",
        "elements": [
          { "elementType": "input", "elementOptions": [{ "type": "number" }], "transformers": [] }
        ]
      },
      "default_value": 3000,
      "localized": ["name", "description"],
      "name": [
        { "language_code": "en_us", "string": "Port" }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Port used by AdGuard Home API. Default is normally <code>3000</code>."
        }
      ]
    },
    {
      "function": "PROTOCOL",
      "type": {
        "dataType": "string",
        "elements": [
          { "elementType": "select", "elementOptions": [], "transformers": [] }
        ]
      },
      "default_value": "http",
      "options": ["http", "https"],
      "localized": ["name", "description"],
      "name": [
        { "language_code": "en_us", "string": "Protocol" }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Choose whether to use HTTP or HTTPS to connect to the AdGuard Home API."
        }
      ]
    },
    {
      "function": "USER",
      "type": {
        "dataType": "string",
        "elements": [
          { "elementType": "input", "elementOptions": [], "transformers": [] }
        ]
      },
      "maxLength": 200,
      "default_value": "",
      "localized": ["name", "description"],
      "name": [
        { "language_code": "en_us", "string": "Username" }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "API username for AdGuard Home. Leave empty if your API does not require login."
        }
      ]
    },
    {
      "function": "PASS",
      "type": {
        "dataType": "string",
        "elements": [
          {
            "elementType": "input",
            "elementOptions": [{ "type": "password" }],
            "transformers": []
          }
        ]
      },
      "maxLength": 200,
      "default_value": "",
      "localized": ["name", "description"],
      "name": [
        { "language_code": "en_us", "string": "Password" }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "API password for AdGuard Home. Leave empty if authentication is disabled."
        }
      ]
    },
    {
      "function": "FAKE_MAC",
      "type": {
        "dataType": "boolean",
        "elements": [
          {
            "elementType": "input",
            "elementOptions": [{ "type": "checkbox" }],
            "transformers": []
          }
        ]
      },
      "default_value": false,
      "localized": ["name", "description"],
      "name": [
        { "language_code": "en_us", "string": "Generate Fake MACs" }
      ],
      "description": [
        {
          "language_code": "en_us",
          "string": "Some devices don't have a MAC assigned. Enabling the FAKE_MAC setting generates a fake MAC address from the IP address to track devices, but it may cause inconsistencies if IPs change or devices are re-discovered with a different MAC. Static IPs are recommended. Device type and icon might not be detected correctly and some plugins might fail if they depend on a valid MAC address. When unchecked, devices with empty MAC addresses are skipped."
        }
      ]
    }
  ],
  "database_column_definitions": [
    {
      "column": "Index",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "none",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Index"
        }
      ]
    },
    {
      "column": "Object_PrimaryID",
      "mapped_to_column": "cur_MAC",
      "css_classes": "col-sm-3",
      "show": true,
      "type": "device_name_mac",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "MAC (name)"
        }
      ]
    },
    {
      "column": "Object_SecondaryID",
      "mapped_to_column": "cur_IP",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "device_ip",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "IP"
        }
      ]
    },
    {
      "column": "Watched_Value1",
      "mapped_to_column": "cur_Name",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Name"
        }
      ]
    },
    {
      "column": "Watched_Value2",
      "mapped_to_column": "cur_Type",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Device Type"
        }
      ]
    },
    {
      "column": "Watched_Value3",
      "css_classes": "col-sm-2",
      "show": false,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "N/A"
        }
      ]
    },
    {
      "column": "Watched_Value4",
      "css_classes": "col-sm-2",
      "show": false,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "N/A"
        }
      ]
    },
    {
      "column": "Dummy",
      "mapped_to_column": "cur_ScanMethod",
      "mapped_to_column_data": {
        "value": "Example Plugin"
      },
      "css_classes": "col-sm-2",
      "show": false,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "ADGUARDIMP"
        }
      ]
    },
    {
      "column": "DateTimeCreated",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Created"
        }
      ]
    },
    {
      "column": "DateTimeChanged",
      "css_classes": "col-sm-2",
      "show": true,
      "type": "label",
      "default_value": "",
      "options": [],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Changed"
        }
      ]
    },
    {
      "column": "Status",
      "css_classes": "col-sm-1",
      "show": true,
      "type": "replace",
      "default_value": "",
      "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>"
        }
      ],
      "localized": ["name"],
      "name": [
        {
          "language_code": "en_us",
          "string": "Status"
        }
      ]
    }
  ]
}
