{
  "pluginAlias": "HomebridgeEconetRheem",
  "pluginType": "platform",
  "singular": true,
  "customUi": true,
  "customUiPath": "./dist/homebridge-ui",
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "type": "string",
        "default": "Econet Rheem"
      },
      "email": {
        "title": "${config.title.email}",
        "type": "string",
        "format": "email"
      },
      "password": {
        "title": "${config.title.password}",
        "type": "string"
      },
      "devices": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "serialNumber": {
              "type": "string",
              "title": "${config.title.serialNumber}"
            },
            "deviceName": {
              "type": "string",
              "title": "${config.title.deviceName}"
            },
            "activeKey": {
              "type": "string",
              "title": "${config.title.activeKey}"
            }
          },
          "allOf": [
            {
              "if": {
                "required": ["serialNumber"]
              },
              "then": {
                  "required": ["deviceName", "activeKey"]
              }
            },
            {
              "if": {
                "required": ["deviceName"]
              },
              "then": {
                  "required": ["serialNumber", "activeKey"]
              }
            },
            {
              "if": {
                "required": ["activeKey"]
              },
              "then": {
                  "required": ["serialNumber", "deviceName"]
              }
            }
          ]
        }
      },
      "enableHistory": {
        "title": "${config.title.enableHistory}",
        "type": "boolean"
      },
      "disableLogging": {
        "title": "${config.title.disableLogging}",
        "type": "boolean"
      },
      "debug": {
        "type": "boolean"
      }
    },
    "allOf": [
      { "required": ["email", "password"] }
    ] 
  },
  "layout": [
    {
      "type": "fieldset",
      "description": "${config.description.account}",
      "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": "${config.title.devices}",
      "description": "${config.description.devices}",
      "items": [
        {
          "type": "array",
          "title": "${config.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%"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}