{
  "pluginAlias": "UniFi Protect",
  "pluginType": "platform",
  "headerDisplay": "Full HomeKit support UniFi Protect devices. See the [homebridge-unifi-protect](https://github.com/hjdhjd/homebridge-unifi-protect) developer page for detailed documentation.",
  "footerDisplay": "A working **FFmpeg** installation is required for this plugin to work. For audio support, make sure your version of ffmpeg is compiled with support for the **fdk-aac** codec.",
  "singular": true,
  "customUi": true,

  "schema": {
    "type": "object",
    "properties": {

      "controllers": {
        "type": "array",
        "title": "UniFi Protect Controllers",

        "items": {
          "type": "object",
          "title": "UniFi Protect Controller",
          "properties": {

            "address": {
              "type": "string",
              "title": "Controller Address",
              "required": true,
              "format": "hostname",
              "placeholder": "e.g. 1.2.3.4",
              "description": "Hostname or IP address of your UniFi Protect controller."
            },

            "doorbellMessages": {
              "type": "array",
              "title": "Doorbell Messages",

              "items": {
                "type": "object",
                "title": "Message Entry Object",

                "properties": {

                  "duration": {
                    "type": "integer",
                    "title": "Message Duration (seconds)",
                    "required": false,
                    "minimum": 0,
                    "placeholder": "e.g. 60",
                    "description": "Length of time to display the message on your doorbell. Use 0 to display the message indefinitely. Default: 60."
                  },

                  "message": {
                    "type": "string",
                    "title": "Message Name",
                    "required": false,
                    "maxLength": 30,
                    "placeholder": "e.g. I'll be there soon.",
                    "description": "Message to display on your doorbell. Default: None."
                  }
                }
              }
            },

            "mqttTopic": {
              "type": "string",
              "title": "MQTT Base Topic",
              "required": false,
              "placeholder": "e.g. unifi/protect",
              "description": "The base MQTT topic to publish to. Default: unifi/protect."
            },

            "mqttUrl": {
              "type": "string",
              "title": "MQTT Broker URL",
              "required": false,
              "format": "uri",
              "placeholder": "e.g. mqtt://1.2.3.4",
              "description": "URL for the MQTT broker you'd like to publish event messages to. Default: None."
            },

            "name": {
              "type": "string",
              "title": "Controller Name",
              "required": false,
              "placeholder": "e.g. UNVR",
              "description": "Name for this UniFi Protect controller to be used for logging purposes. Default: Defined by the controller."
            },

            "overrideAddress": {

              "type": "string",
              "title": "Override Controller Address",
              "required": false,
              "description": "Override the address used when livestreaming. This is useful in VPN and remote scenarios where you want to override the address of the UniFi Protect controller. Warning: due to the way stacked Protect controller installations work, this option is unavailable for those configurations."
            },

            "password": {
              "type": "string",
              "title": "Controller Password",
              "required": true,
              "placeholder": "e.g. unifi-protect-password",
              "description": "UniFi Protect password for this controller. Creating a homebridge-specific local user is strongly encouraged for security and sanity."
            },

            "username": {
              "type": "string",
              "title": "Controller Username",
              "required": true,
              "placeholder": "e.g. some-unifi-protect-user",
              "description": "UniFi Protect username for this controller. Creating a homebridge-specific local user is strongly encouraged for security and sanity."
            }
          }
        }
      },

      "name": {

        "type": "string",
        "title": "Plugin Name",
        "required": true,
        "default": "UniFi Protect",
        "description": "Name to use for Homebridge logging purposes. Default: UniFi Protect."
      },

      "options": {

        "type": "array",
        "title": "Feature Options",

        "items": {
          "type": "string",
          "title": "Feature Option",
          "required": false,
          "description": "Enter only one option per entry. Use the feature options webUI tab above unless you know what you're doing.",
          "placeholder": "e.g. Disable.Device"
        }
      },

      "ringDelay": {

        "type": "integer",
        "title": "Doorbell Ring Delay (seconds)",
        "required": false,
        "minimum": 0,
        "maximum": 60,
        "placeholder": "e.g. 5",
        "description": "Delay between doorbell rings. Setting this to a non-zero value will prevent multiple rings of a doorbell over the specified duration.  Default: 0."
      },

      "verboseFfmpeg": {

        "type": "boolean",
        "title": "Verbose FFmpeg Logging",
        "required": false,
        "description": "Enable additional logging for FFmpeg. This will create additional logging when video streams are running. Default: false."
      },

      "videoProcessor": {

        "type": "string",
        "title": "FFmpeg Location",
        "required": false,
        "placeholder": "e.g. /usr/local/bin/ffmpeg",
        "description": "Path to the FFmpeg executable. Most users should not use this setting - FFmpeg is already bundled in the plugin for many platforms. Default: bundled build or the first ffmpeg found in PATH."
      }
    }
  },

  "layout": [
    {
      "type": "section",
      "title": "UniFi Protect Controllers",
      "expandable": true,
      "expanded": false,
      "items": [
        {
          "key": "controllers",
          "type": "array",
          "name": " ",
          "description": "Provide the IP address and login details of your UniFi Protect controllers.",
          "orderable": false,
          "buttonText": "Add UniFi Protect Controller",
          "items": [
            "controllers[].address",
            "controllers[].username",
            "controllers[].password",

            {
              "key": "controllers[]",
              "type": "section",
              "title": "Doorbell Message Presets",
              "expandable": true,
              "expanded": false,
              "items": [

                {
                  "key": "controllers[].doorbellMessages",
                  "type": "array",
                  "name": " ",
                  "description": "Create additional message presets to display on your UniFi Protect Doorbell.",
                  "orderable": false,
                  "buttonText": "Add Doorbell Message",
                  "items": [
                    "controllers[].doorbellMessages[].message",
                    "controllers[].doorbellMessages[].duration"
                  ]
                }
              ]
            },

            {
              "key": "controllers[]",
              "type": "section",
              "title": "Optional Settings",
              "expandable": true,
              "expanded": false,
              "items": [
                {
                  "description": "These settings are optional. The defaults work well for almost everyone.",
                  "items": [
                    "controllers[].name",
                    "controllers[].overrideAddress"
                  ]
                }
              ]
            },
            {
              "key": "controllers[]",
              "type": "section",
              "title": "MQTT Settings",
              "expandable": true,
              "expanded": false,
              "items": [
                {
                  "description": "MQTT support will only be enabled if an MQTT broker URL is specified below.",
                  "items": [
                    "controllers[].mqttUrl",
                    "controllers[].mqttTopic"
                  ]
                }
              ]
            }
          ]
        }
      ]
    },

    {
      "type": "section",
      "title": "Plugin Feature Options (Optional)",
      "expandable": true,
      "expanded": false,
      "items": [
        {
          "key": "options",
          "type": "array",
          "name": " ",
          "description": "Use the feature options webUI tab above instead of manually configuring feature options here.",
          "orderable": true,
          "buttonText": "Add Feature Option",
          "items": [
            "options[]"
          ]
        }
      ]
    },

    {
      "type": "section",
      "title": "Additional Settings (Optional)",
      "expandable": true,
      "expanded": false,
      "items": [
        {
          "description": "These settings should be rarely used or needed by most people. Use these with caution.",
          "items": [
            "name",
            "videoProcessor",
            "verboseFfmpeg",
            "ringDelay"
          ]
        }
      ]
    }
  ]
}
