{
  "pluginAlias": "HomebridgeEconetRheem",
  "pluginType": "platform",
  "singular": true,
  "customUi": true,
  "customUiPath": "./dist/homebridge-ui",
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "type": "string",
        "default": "Econet Rheem"
      },
      "email": {
        "title": "Email",
        "type": "string",
        "format": "email"
      },
      "password": {
        "title": "Password",
        "type": "string"
      },
      "devices": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "serialNumber": {
              "type": "string",
              "title": "Serial Number"
            },
            "deviceName": {
              "type": "string",
              "title": "Device Name"
            },
            "activeKey": {
              "type": "string",
              "title": "Active Key"
            }
          },
          "allOf": [
            {
              "if": {
                "required": ["serialNumber"]
              },
              "then": {
                  "required": ["deviceName", "activeKey"]
              }
            },
            {
              "if": {
                "required": ["deviceName"]
              },
              "then": {
                  "required": ["serialNumber", "activeKey"]
              }
            },
            {
              "if": {
                "required": ["activeKey"]
              },
              "then": {
                  "required": ["serialNumber", "deviceName"]
              }
            }
          ]
        }
      },
      "enableHistory": {
        "title": "Enable History",
        "type": "boolean"
      },
      "disableLogging": {
        "title": "Disable Logging",
        "type": "boolean"
      },
      "debug": {
        "type": "boolean"
      }
    },
    "allOf": [
      { "required": ["email", "password"] }
    ] 
  },
  "layout": [
    {
      "type": "fieldset",
      "description": "Dedicated account recommended. See documentation.",
      "notitle": true,
      "items": [
        {
          "type": "div",
          "displayFlex": true,
          "flex-direction": "row",
          "items": [
            {
              "key": "email",
              "flex": "0 0 50%"
            },
            {
              "key": "password",
              "flex": "0 0 50%"
            }
          ]
        }
      ]
    },
    {
      "type": "div",
      "displayFlex": true,
      "flex-direction": "row",
      "items": [
        {
          "key": "enableHistory",
          "flex": "0 1 25%"
        },
        {
          "key": "disableLogging",
          "flex": "0 1 25%"
        }
      ]
    },
    {
      "type": "fieldset",
      "title": "Devices",
      "description": "Providing additional device details gives a better experience. See documentation for details.",
      "items": [
        {
          "type": "array",
          "title": "Device",
          "notitle": true,
          "key": "devices",
          "items": [
            {
              "type": "div",
              "displayFlex": true,
              "flex-direction": "row",
              "items": [
                {
                  "key": "devices[].serialNumber",
                  "flex": "0 0 33%"
                },
                {
                  "key": "devices[].deviceName",
                  "flex": "0 0 33%"
                },
                {
                  "key": "devices[].activeKey",
                  "flex": "0 0 33%"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}