{
  "pluginAlias": "config",
  "pluginType": "platform",
  "singular": true,
  "strictValidation": true,
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "title": "Name",
        "type": "string",
        "default": "Homebridge UI",
        "minLength": 1,
        "required": true,
        "description": "The name of the Homebridge instance."
      },
      "port": {
        "title": "Port",
        "type": "integer",
        "default": 8080,
        "maximum": 65535,
        "required": true,
        "description": "The port number to run the Homebridge UI on."
      },
      "auth": {
        "title": "Homebridge UI Authentication",
        "type": "string",
        "default": "form",
        "description": "The type of authentication to use for the Homebridge UI.",
        "oneOf": [
          {
            "title": "Require Authentication",
            "enum": [
              "form"
            ]
          },
          {
            "title": "None",
            "enum": [
              "none"
            ]
          }
        ],
        "required": true
      },
      "theme": {
        "title": "UI Theme",
        "description": "The theme used for the UI.",
        "type": "string",
        "default": "orange",
        "oneOf": [
          {
            "title": "Orange",
            "enum": [
              "orange"
            ]
          },
          {
            "title": "Red",
            "enum": [
              "red"
            ]
          },
          {
            "title": "Pink",
            "enum": [
              "pink"
            ]
          },
          {
            "title": "Purple",
            "enum": [
              "purple"
            ]
          },
          {
            "title": "Deep Purple",
            "enum": [
              "deep-purple"
            ]
          },
          {
            "title": "Indigo",
            "enum": [
              "indigo"
            ]
          },
          {
            "title": "Blue",
            "enum": [
              "blue"
            ]
          },
          {
            "title": "Blue Grey",
            "enum": [
              "blue-grey"
            ]
          },
          {
            "title": "Cyan",
            "enum": [
              "cyan"
            ]
          },
          {
            "title": "Green",
            "enum": [
              "green"
            ]
          },
          {
            "title": "Teal",
            "enum": [
              "teal"
            ]
          },
          {
            "title": "Grey",
            "enum": [
              "grey"
            ]
          },
          {
            "title": "Brown",
            "enum": [
              "brown"
            ]
          }
        ],
        "required": true
      },
      "lightingMode": {
        "title": "UI Lighting Mode",
        "description": "The lighting mode used for the UI.",
        "type": "string",
        "default": "auto",
        "oneOf": [
          {
            "title": "Auto",
            "enum": [
              "auto"
            ]
          },
          {
            "title": "Light",
            "enum": [
              "light"
            ]
          },
          {
            "title": "Dark",
            "enum": [
              "dark"
            ]
          }
        ]
      },
      "menuMode": {
        "title": "Menu Mode",
        "description": "Modes for the UI side menu.",
        "type": "string",
        "default": "default",
        "oneOf": [
          {
            "title": "Default",
            "enum": [
              "default"
            ]
          },
          {
            "title": "Freeze",
            "enum": [
              "freeze"
            ]
          }
        ]
      },
      "restart": {
        "title": "Custom Restart Command",
        "type": "string",
        "description": "If no restart command is set the process will terminate with a non-zero exit code.",
        "placeholder": "eg. sudo systemctl restart homebridge"
      },
      "temp": {
        "title": "OS Temp File Path",
        "type": "string",
        "placeholder": "eg. /sys/class/thermal/thermal_zone0/temp",
        "description": "If you are running Homebridge on a Raspberry Pi, you can enter the path to the OS temp file here. This will display the current temperature on the Homebridge status page."
      },
      "tempUnits": {
        "title": "Temperature Display Units",
        "description": "The units used to display the temperature.",
        "type": "string",
        "required": true,
        "default": "c",
        "oneOf": [
          {
            "title": "Celsius",
            "enum": [
              "c"
            ]
          },
          {
            "title": "Fahrenheit",
            "enum": [
              "f"
            ]
          }
        ]
      },
      "lang": {
        "title": "Language",
        "type": "string",
        "default": "auto",
        "description": "The language used for the UI.",
        "required": true,
        "oneOf": [
          {
            "title": "Automatic (Use Browser Settings)",
            "enum": [
              "auto"
            ]
          },
          {
            "title": "Bulgarian (bg)",
            "enum": [
              "bg"
            ]
          },
          {
            "title": "Catalan (ca)",
            "enum": [
              "ca"
            ]
          },
          {
            "title": "Chinese - Simplified (zh-CN)",
            "enum": [
              "zh-CN"
            ]
          },
          {
            "title": "Chinese - Traditional (zh-TW)",
            "enum": [
              "zh-TW"
            ]
          },
          {
            "title": "Czech (cs)",
            "enum": [
              "cs"
            ]
          },
          {
            "title": "Dutch (nl)",
            "enum": [
              "nl"
            ]
          },
          {
            "title": "English (en)",
            "enum": [
              "en"
            ]
          },
          {
            "title": "Finnish (fi)",
            "enum": [
              "fi"
            ]
          },
          {
            "title": "French (fr)",
            "enum": [
              "fr"
            ]
          },
          {
            "title": "German (de)",
            "enum": [
              "de"
            ]
          },
          {
            "title": "Hebrew (he)",
            "enum": [
              "he"
            ]
          },
          {
            "title": "Hungarian (hu)",
            "enum": [
              "hu"
            ]
          },
          {
            "title": "Indonesian (id)",
            "enum": [
              "id"
            ]
          },
          {
            "title": "Italian (it)",
            "enum": [
              "it"
            ]
          },
          {
            "title": "Japanese (ja)",
            "enum": [
              "ja"
            ]
          },
          {
            "title": "Korean (ko)",
            "enum": [
              "ko"
            ]
          },
          {
            "title": "Macedonian (mk)",
            "enum": [
              "mk"
            ]
          },
          {
            "title": "Norwegian (no)",
            "enum": [
              "no"
            ]
          },
          {
            "title": "Polish (pl)",
            "enum": [
              "pl"
            ]
          },
          {
            "title": "Portuguese (Brazil)",
            "enum": [
              "pt-BR"
            ]
          },
          {
            "title": "Portuguese (Portugal)",
            "enum": [
              "pt"
            ]
          },
          {
            "title": "Russian (ru)",
            "enum": [
              "ru"
            ]
          },
          {
            "title": "Slovenian (sl)",
            "enum": [
              "sl"
            ]
          },
          {
            "title": "Spanish (es)",
            "enum": [
              "es"
            ]
          },
          {
            "title": "Swedish (sv)",
            "enum": [
              "sv"
            ]
          },
          {
            "title": "Thai (th)",
            "enum": [
              "th"
            ]
          },
          {
            "title": "Turkish (tr)",
            "enum": [
              "tr"
            ]
          },
          {
            "title": "Ukrainian (uk)",
            "enum": [
              "uk"
            ]
          }
        ]
      },
      "loginWallpaper": {
        "title": "Login Wallpaper Path",
        "description": "The full path to the .jpg file.",
        "type": "string",
        "placeholder": "eg. /home/pi/mywallpaper.jpg"
      },
      "sudo": {
        "title": "Use Sudo",
        "type": "boolean",
        "description": "If you are running Homebridge as root, you may need to enable this option."
      },
      "homebridgePackagePath": {
        "title": "Path To Homebridge Module",
        "type": "string",
        "description": "If you have multiple versions of Homebridge installed, you can specify the path to the version you want to use here.",
        "placeholder": "eg. /usr/local/lib/node_modules/homebridge"
      },
      "noFork": {
        "title": "Do not run the UI server in a separate process/thread",
        "type": "boolean",
        "description": "If you are running Homebridge in a container, you may need to enable this option."
      },
      "host": {
        "title": "Host IP Address",
        "type": "string",
        "pattern": "^[^{}/ :\\\\]+(?::\\d+)?$",
        "description": "The host IP address to listen on. In most cases this will be '::' or '0.0.0.0'.",
        "placeholder": "eg. 0.0.0.0"
      },
      "debug": {
        "title": "Enable Debug Logging",
        "type": "boolean",
        "description": "If enabled, the Homebridge UI will log debug level messages to the console."
      },
      "standalone": {
        "title": "Tell Homebridge the plugin is operating in standalone mode",
        "type": "boolean",
        "description": "If you are running Homebridge in a container, you may need to enable this option."
      },
      "sessionTimeout": {
        "title": "Session Timeout (Seconds)",
        "type": "integer",
        "placeholder": 28800,
        "minimum": 600,
        "maximum": 86400000,
        "description": "The number of seconds before a user session will timeout. Defaults to 8 hours.",
        "condition": {
          "functionBody": "return model.auth === 'form'"
        }
      },
      "log": {
        "type": "object",
        "title": "Log Settings",
        "description": "The log settings for the Homebridge UI.",
        "properties": {
          "method": {
            "title": "Log Method",
            "type": "string",
            "default": "",
            "description": "The method used to read the Homebridge log file.",
            "oneOf": [
              {
                "title": "Default",
                "enum": [
                  ""
                ]
              },
              {
                "title": "From File",
                "enum": [
                  "file"
                ]
              },
              {
                "title": "Systemd",
                "enum": [
                  "systemd"
                ]
              },
              {
                "title": "Custom Command",
                "enum": [
                  "custom"
                ]
              }
            ]
          },
          "path": {
            "title": "Log File Path",
            "type": "string",
            "description": "Enter the full file path to your log file.",
            "placeholder": "/var/log/homebridge.log",
            "condition": {
              "functionBody": "return (model.log && model.log.method==='file')"
            }
          },
          "service": {
            "title": "Systemd Service",
            "type": "string",
            "description": "Enter the systemd service name. Defaults to 'homebridge'.",
            "placeholder": "homebridge",
            "condition": {
              "functionBody": "return (model.log && model.log.method==='systemd')"
            }
          },
          "command": {
            "title": "Custom Command",
            "description": "This command should stream the logs to stdout.",
            "type": "string",
            "placeholder": "journalctl -f -n 100 -u homebridge",
            "condition": {
              "functionBody": "return (model.log && model.log.method==='custom')"
            }
          },
          "tail": {
            "type": "string",
            "description": "Deprecated.",
            "condition": {
              "functionBody": "return (model.log && (model.log.method==='custom' || model.log.method==='systemd' || model.log.method==='file'))"
            }
          },
          "systemd": {
            "type": "string",
            "description": "Deprecated.",
            "condition": {
              "functionBody": "return (model.log && (model.log.method==='custom' || model.log.method==='systemd' || model.log.method==='file'))"
            }
          },
          "maxSize": {
            "type": "integer",
            "description": "The max log size (bytes). Set to -1 to disable log truncation.",
            "minimum": -1
          },
          "truncateSize": {
            "type": "integer",
            "description": "The size (bytes) to truncate the log to once it goes over the max size specified above.",
            "minimum": 0,
            "condition": {
              "functionBody": "return (model.log && model.log.maxSize > 0)"
            }
          }
        }
      },
      "ssl": {
        "title": "SSL Setup",
        "type": "object",
        "description": "The SSL settings for the Homebridge UI.",
        "properties": {
          "key": {
            "title": "Private Key Path",
            "type": "string",
            "description": "The full path to the private key file.",
            "placeholder": "eg. /Users/homebridge/.homebridge/certs/server.key"
          },
          "cert": {
            "title": "Certificate Path",
            "type": "string",
            "description": "The full path to the certificate file.",
            "placeholder": "eg. /Users/homebridge/.homebridge/certs/server.crt"
          },
          "pfx": {
            "title": "PKCS#12 Certificate Path",
            "type": "string",
            "description": "The full path to the PKCS#12 certificate file.",
            "placeholder": "eg. /Users/homebridge/.homebridge/certs/server.pfx"
          },
          "passphrase": {
            "title": "PKCS#12 Certificate Passphrase",
            "type": "string",
            "description": "The passphrase for the PKCS#12 certificate file.",
            "placeholder": "eg. mypassphrase"
          }
        }
      },
      "accessoryControl": {
        "title": "Accessory Control Setup",
        "type": "object",
        "description": "The accessory control settings for the Homebridge UI.",
        "properties": {
          "debug": {
            "title": "Enable Accessory Control Debug Logging",
            "type": "boolean",
            "description": "If enabled, the Homebridge UI will log debug level messages to the console."
          },
          "instanceBlacklist": {
            "title": "Blacklisted Bridges/Instances",
            "type": "array",
            "description": "A list of instances (or bridge usernames) that should not be controlled via the web UI.",
            "placeholder": "eg. 00:00:00:00:00:00",
            "items": {
              "title": "Instance Username",
              "type": "string",
              "pattern": "^([A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2}$"
            }
          }
        }
      },
      "linux": {
        "title": "Linux Server Commands",
        "type": "object",
        "description": "The Linux server commands for the Homebridge UI.",
        "properties": {
          "shutdown": {
            "title": "Shutdown Command",
            "type": "string",
            "placeholder": "eg. shutdown",
            "description": "If no shutdown command is set the process will terminate with a non-zero exit code."
          },
          "restart": {
            "title": "Restart Command",
            "type": "string",
            "placeholder": "eg. reboot",
            "description": "If no restart command is set the process will terminate with a non-zero exit code."
          }
        }
      },
      "proxyHost": {
        "title": "Reverse Proxy Hostname",
        "type": "string",
        "pattern": "^[^{}/ :\\\\]+(?::\\d+)?$",
        "placeholder": "eg. example.com:8443",
        "description": "When running behind a reverse proxy you may need to enter the hostname you use to access the UI."
      },
      "scheduledBackupPath": {
        "title": "Scheduled Backup Destination",
        "description": "The full path to where the service should save daily scheduled backups archives.",
        "type": "string",
        "placeholder": "eg. /home/pi/homebridge-backups",
        "condition": {
          "functionBody": "return !model.scheduledBackupDisable"
        }
      },
      "scheduledBackupDisable": {
        "title": "Disable Scheduled Backups",
        "type": "boolean",
        "description": "When enabled, the Homebridge UI will not create daily scheduled backups."
      },
      "disableServerMetricsMonitoring": {
        "title": "Disable Server Metrics Monitoring",
        "type": "boolean",
        "description": "When enabled, the Homebridge UI will not collect or report CPU or memory stats."
      }
    }
  },
  "layout": [
    {
      "ref": "login",
      "type": "fieldset",
      "expandable": true,
      "title": "Login Settings",
      "items": [
        "auth",
        {
          "key": "sessionTimeout",
          "type": "number"
        }
      ]
    },
    {
      "ref": "log",
      "type": "fieldset",
      "expandable": true,
      "title": "Log Settings",
      "items": [
        "debug",
        "log.method",
        "log.path",
        "log.service",
        "log.command",
        "log.tail",
        "log.systemd"
      ]
    },
    {
      "ref": "logRetention",
      "type": "fieldset",
      "expandable": true,
      "title": "Log Retention Settings",
      "items": [
        "log.maxSize",
        "log.truncateSize"
      ]
    },
    {
      "ref": "accessoryControl",
      "type": "fieldset",
      "expandable": true,
      "title": "Accessory Control",
      "items": [
        "accessoryControl.debug",
        {
          "key": "accessoryControl.instanceBlacklist",
          "type": "array",
          "items": {
            "key": "accessoryControl.instanceBlacklist[]",
            "type": "string",
            "pattern": "^([A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2}$",
            "title": "Instance Username"
          }
        }
      ]
    },
    {
      "ref": "hostname",
      "type": "fieldset",
      "expandable": true,
      "title": "Hostname Settings",
      "items": [
        "proxyHost",
        "host"
      ]
    },
    {
      "ref": "ssl",
      "type": "fieldset",
      "expandable": true,
      "title": "SSL Settings",
      "items": [
        "ssl.key",
        "ssl.cert",
        "ssl.pfx",
        "ssl.passphrase"
      ]
    },
    {
      "ref": "homebridge",
      "type": "fieldset",
      "expandable": true,
      "title": "Homebridge Settings",
      "items": [
        "sudo",
        "restart",
        "homebridgePackagePath"
      ]
    },
    {
      "ref": "operatingSystem",
      "type": "fieldset",
      "expandable": true,
      "title": "Operating System Specific Settings",
      "items": [
        "disableServerMetricsMonitoring",
        {
          "ref": "linux",
          "type": "fieldset",
          "expandable": true,
          "title": "Linux Settings",
          "items": [
            "linux.shutdown",
            "linux.restart",
            "temp"
          ]
        },
        {
          "ref": "container",
          "type": "fieldset",
          "expandable": true,
          "title": "Container Settings",
          "items": [
            "standalone",
            "noFork"
          ]
        }
      ]
    },
    {
      "ref": "scheduledBackup",
      "type": "fieldset",
      "expandable": true,
      "title": "Scheduled Backup Settings",
      "items": [
        "scheduledBackupDisable",
        "scheduledBackupPath"
      ]
    }
  ]
}
