{
  "pluginAlias": "UniFiSmartPower",
  "pluginType": "platform",
  "singular": true,
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "title": "Name",
        "type": "string",
        "default": "UniFi SmartPower",
        "minLength": 1,
        "required": true
      },
      "host": {
        "title": "UniFi Network Host/IP Address",
        "type": "string",
        "default": "192.168.1.1",
        "minLength": 3,
        "required": true
      },
      "port": {
        "title": "UniFi Network Port",
        "type": "integer",
        "default": 443,
        "minimum": 1,
        "required": true
      },
      "username": {
        "title": "User Name",
        "type": "string",
        "default": "ubnt",
        "required": true
      },
      "password": {
        "title": "Password",
        "type": "string",
        "default": "ubnt",
        "required": true,
        "options": {
          "hidden": true
        }
      },
      "controlSwitch": {
        "type": "object",
        "default": {},
        "required": false,
        "properties": {
          "create": {
            "title": "Create Switch",
            "type": "boolean",
            "default": false,
            "required": false
          },
          "name": {
            "title": "Name",
            "type": "string",
            "default": "UniFi Control Enabled",
            "minLength": 1,
            "required": false
          },
          "timeout": {
            "title": "Timeout",
            "description": "Number of seconds before the control switch reverts. 0 disables the timeout.",
            "type": "integer",
            "default": 60,
            "minimum": 0,
            "required": false
          },
          "guardOutlets": {
            "title": "Guard Outlets",
            "description": "If true, outlets will be guarded by this control switch.",
            "type": "boolean",
            "default": true,
            "required": false
          },
          "guardSwitchPorts": {
            "title": "Guard Switch Ports",
            "description": "If true, switch ports will be guarded by this control switch.",
            "type": "boolean",
            "default": true,
            "required": false
          }
        }
      },
      "includeSites": {
        "title": "Include Sites",
        "type": "array",
        "default": [],
        "required": false,
        "items": {
          "title": "Site ID",
          "type": "string"
        }
      },
      "excludeSites": {
        "title": "Exclude Sites",
        "type": "array",
        "default": [],
        "required": false,
        "items": {
          "title": "Site ID",
          "type": "string"
        }
      },
      "includeDevices": {
        "title": "Include Devices",
        "type": "array",
        "default": [],
        "required": false,
        "items": {
          "title": "Device ID",
          "type": "string"
        }
      },
      "excludeDevices": {
        "title": "Exclude Devices",
        "type": "array",
        "default": [],
        "required": false,
        "items": {
          "title": "Device ID",
          "type": "string"
        }
      },
      "includeOutlets": {
        "title": "Include Outlets",
        "type": "array",
        "default": [],
        "required": false,
        "items": {
          "title": "Outlet ID",
          "type": "string"
        }
      },
      "excludeOutlets": {
        "title": "Exclude Outlets",
        "type": "array",
        "default": [],
        "required": false,
        "items": {
          "title": "Outlet ID",
          "type": "string"
        }
      },
      "includePorts": {
        "title": "Include Ports",
        "type": "array",
        "default": [],
        "required": false,
        "items": {
          "title": "Port ID",
          "type": "string"
        }
      },
      "excludePorts": {
        "title": "Exclude Ports",
        "type": "array",
        "default": [],
        "required": false,
        "items": {
          "title": "Port ID",
          "type": "string"
        }
      },
      "includeInactivePorts": {
        "title": "Show ports that are not supplying PoE power",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "includeRpsPorts": {
        "title": "Include RPS Ports",
        "type": "array",
        "default": [],
        "required": false,
        "items": {
          "title": "RPS Port ID",
          "type": "string"
        }
      },
      "excludeRpsPorts": {
        "title": "Exclude RPS Ports",
        "type": "array",
        "default": [],
        "required": false,
        "items": {
          "title": "RPS Port ID",
          "type": "string"
        }
      },
      "includeInactiveRpsPorts": {
        "title": "Show RPS ports that are not connected",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "refreshDevicesPollInterval": {
        "title": "Refresh Devices Poll Interval (in seconds)",
        "type": "integer",
        "default": 600,
        "minimum": 120,
        "maximum": 3600,
        "required": true
      },
      "outletStatusCacheTtl": {
        "title": "Outlet Status Cache TTL (in seconds)",
        "type": "integer",
        "default": 15,
        "minimum": 5,
        "maximum": 60,
        "required": true
      },
      "outletStatusPollInterval": {
        "title": "Outlet Status Poll Interval (in seconds)",
        "type": "integer",
        "default": 15,
        "minimum": 5,
        "maximum": 60,
        "required": true
      },
      "logApiResponses": {
        "title": "Log API responses during startup",
        "type": "boolean",
        "default": false
      }
    }
  },
  "layout": [
    "name",
    "host",
    "port",
    "username",
    "password",
    {
      "type": "section",
      "title": "Advanced Settings",
      "expandable": true,
      "expanded": false,
      "items": [
        {
          "type": "section",
          "title": "Control Switch",
          "items": [
            "controlSwitch.create",
            "controlSwitch.name",
            "controlSwitch.timeout",
            "controlSwitch.guardOutlets",
            "controlSwitch.guardSwitchPorts"
          ]
        },
        {
          "key": "includeSites",
          "type": "array",
          "name": "Included Sites",
          "orderable": false,
          "items": ["includeSites[]"]
        },
        {
          "key": "excludeSites",
          "type": "array",
          "name": "Excluded Sites",
          "orderable": false,
          "items": ["excludeSites[]"]
        },
        {
          "key": "includeDevices",
          "type": "array",
          "name": "Included Devices",
          "orderable": false,
          "items": ["includeDevices[]"]
        },
        {
          "key": "excludeDevices",
          "type": "array",
          "name": "Excluded Devices",
          "orderable": false,
          "items": ["excludeDevices[]"]
        },
        {
          "key": "includeOutlets",
          "type": "array",
          "name": "Included Outlets",
          "orderable": false,
          "items": ["includeOutlets[]"]
        },
        {
          "key": "excludeOutlets",
          "type": "array",
          "name": "Excluded Outlets",
          "orderable": false,
          "items": ["excludeOutlets[]"]
        },
        {
          "key": "includePorts",
          "type": "array",
          "name": "Included Ports",
          "orderable": false,
          "items": ["includePorts[]"]
        },
        {
          "key": "excludePorts",
          "type": "array",
          "name": "Excluded Ports",
          "orderable": false,
          "items": ["excludePorts[]"]
        },
        "includeInactivePorts",
        {
          "key": "includeRpsPorts",
          "type": "array",
          "name": "Included RPS Ports",
          "orderable": false,
          "items": ["includeRpsPorts[]"]
        },
        {
          "key": "excludeRpsPorts",
          "type": "array",
          "name": "Excluded RPS Ports",
          "orderable": false,
          "items": ["excludeRpsPorts[]"]
        },
        "includeInactiveRpsPorts",
        "refreshDevicesPollInterval",
        "outletStatusCacheTtl",
        "outletStatusPollInterval",
        "logApiResponses"
      ]
    }
  ]
}
