{
  "pluginAlias": "RinnaiTouchPlatform",
  "pluginType": "platform",
  "singular": false,
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "title": "Name",
        "type": "string",
        "default": "Rinnai Touch",
        "required": true
      },
      "address": {
        "title": "IP Address",
        "description": "(leave blank for automatic discovery)",
        "type": "string",
        "format": "ipv4"
      },
      "port": {
        "title": "Port",
        "type": "number",
        "placeholder": 27847,
        "minimum": 0,
        "maximum": 65535
      },
      "controllerType": {
        "title": "Controller Accessory Type",
        "description": "",
        "type": "string",
        "required": true,
        "default": "T",
        "oneOf":  [
          { "title": "Thermostat", "enum": [ "T" ] },
          { "title": "Heater Cooler", "enum": [ "H" ] }
        ]
      },
      "zoneType": {
        "title": "Zone Accessory Type",
        "description": "",
        "type": "string",
        "required": true,
        "default": "S",
        "oneOf":  [
          { "title": "None", "enum": [ "N" ] },
          { "title": "Switch", "enum": [ "S" ] },
          { "title": "Heater Cooler", "enum": [ "H" ] }
        ]
      },
      "showFan": {
        "title": "Show 'Fan' accessory",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "showAuto": {
        "title": "Show 'AUTO' option in Thermostat/Heater Cooler",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "showAdvanceSwitches": {
        "title": "Show 'Advance Period' switch accessory(ies)",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "showManualSwitches": {
        "title": "Show 'Manual' switch accessory(ies)",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "seperateModeAccessories": {
        "title": "Seperate accessories for each mode (heat & cool)",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "seperateFanZoneSwitches": {
        "title": "Seperate zone switches for circlulation fan",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "invertComfortLevel": {
        "title": "Invert Comfort Level when setting temperature",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "setAutoOperatingState": {
        "title": "Set Operating state to 'AUTO' when setting temperature",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "showHomebridgeEvents": {
        "title": "Show Homebridge events in the log",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "showModuleEvents": {
        "title": "Show Rinnai Touch Module events in the log",
        "type": "boolean",
        "default": true,
        "required": false
      },  
      "showModuleStatus": {
        "title": "Show Rinnai Touch Module status in the log",
        "type": "boolean",
        "default": false,
        "required": false
      },  
      "clearCache": {
        "title": "Clear plugin's accessory cache",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "forceAutoDiscovery": {
        "title": "Force auto-discovery",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "bootTime": {
        "title": "Module Boot Time (24 hour format)",
        "description": "(leave blank to prevent boot)",
        "type": "string",
        "required": false,
        "placeholder": "hh:mm",
        "pattern": "^(2[0-3]|[0-1][0-9]):[0-5][0-9]$"
      },
      "bootPassword": {
        "title": "Module's Default Security Key (WPA)",
        "description": "(required for booting module)",
        "type": "string",
        "required": false
      },
      "mqtt": {
        "type": "object",
        "properties": {
          "host": {
            "title": "Broker Host Name",
            "type": "string",
            "placeholder": "mqtt://localhost"
          },
          "port": {
            "title": "Port",
            "type": "number",
            "placeholder": 1883,
            "minimum": 0,
            "maximum": 65535
          },
          "username": {
            "title": "Username",
            "type": "string"
          },
          "password": {
            "title": "Password",
            "type": "string"
          },
          "topicPrefix": {
            "title": "Topic Prefix",
            "type": "string"
          },
          "formatHomeAssistant": {
            "title": "Home Assistant",
            "type": "boolean"
          },
          "formatConnection": {
            "title": "Module Connection",
            "type": "boolean"
          },
          "formatFault": {
            "title": "Fault Status",
            "type": "boolean"
          },          
          "publishStatusChanged": {
            "title": "When status has changed",
            "type": "boolean"
          },
          "publishIntervals": {
            "title": "At regular intervals",
            "type": "boolean"
          },
          "publishFrequency": {
            "title": "Publish Frequency (secs)",
            "type": "number",
            "placeholder": 60,
            "minimum": 1,
            "maximum": 86400
          },
          "publishAll": {
            "title": "Publish all topics even if payload has not changed",
            "type": "boolean"              
          },
          "showMqttEvents": {
            "title": "Show MQTT events in the log",
            "type": "boolean",
            "default": true,
            "required": false
          }, 
          "subscribeTemperature": {
            "type": "object",
            "properties": {
              "U": {
                "type": "string",
                "title": "Zone U (Common) Topic"
              },
              "A": {
                "type": "string",
                "title": "Zone A Topic"
              },
              "B": {
                "type": "string",
                "title": "Zone B Topic"
              },
              "C": {
                "type": "string",
                "title": "Zone C Topic"
              },
              "D": {
                "type": "string",
                "title": "Zone D Topic"
              },
              "jsonPathU": {
                "type": "string",
                "title": "JSONPath"
              },
              "jsonPathA": {
                "type": "string",
                "title": "JSONPath"
              },
              "jsonPathB": {
                "type": "string",
                "title": "JSONPath"
              },
              "jsonPathC": {
                "type": "string",
                "title": "JSONPath"
              },
              "jsonPathD": {
                "type": "string",
                "title": "JSONPath"
              }
            }
          }
        }
      },
      "pushover": {
        "type": "object",
        "properties": {
          "token": {
            "title": "Application Token",
            "type": "string",
            "required": false
          },
          "users": {
            "title": "User Keys",
            "type": "array",
            "items": {
              "title": "User Key",
              "type": "string"
            }
          },
          "minTemperatureThreshold": {
            "title": "Minimum Temperature Threshold",
            "type": "number",
            "minimum": 8,
            "maximum": 30
          },
          "maxTemperatureThreshold": {
            "title": "Maximum Temperature Threshold",
            "type": "number",
            "minimum": 8,
            "maximum": 30
          },
          "connectionError": {
            "title": "Connection Error",
            "type": "boolean"
          },
          "faultDetected": {
            "title": "Fault Detected",
            "type": "boolean"
          },
          "dayIncorrect": {
            "title": "Day Incorrect",
            "type": "boolean"
          },
          "timeIncorrect": {
            "title": "Time Incorrect",
            "type": "boolean"
          }
        }
      }
    }
  },
  "layout": [
    "name",
    {
      "type": "flex",
      "flex-flow": "row wrap",
      "items": [ "address", "port" ] 
    },
    {
      "type": "fieldset",
      "title": "Accessory Settings",
      "expandable": true,
      "expanded": false,
      "items": [
        {
          "type": "flex",
          "flex-flow": "row wrap",
          "items": [ "controllerType", "zoneType" ]          
        },
        "showFan",
        "showAuto",
        "showAdvanceSwitches",
        "showManualSwitches",
        "seperateModeAccessories",
        "seperateFanZoneSwitches"
      ]
    },
    {
      "type": "fieldset",
      "title": "Evaporative Cooler Settings",
      "expandable": true,
      "expanded": false,
      "items": [
        "invertComfortLevel",
        "setAutoOperatingState"
      ]
    },
    {
      "type": "fieldset",
      "title": "MQTT Settings",
      "expandable": true,
      "expanded": false,
      "items": [
        {
          "type": "flex",
          "flex-flow": "row wrap",
          "items": [ "mqtt.host", "mqtt.port" ] 
        },
        {
          "type": "flex",
          "flex-flow": "row wrap",
          "items": [ "mqtt.username", "mqtt.password" ] 
        },
        {
          "type": "flex",
          "flex-flow": "row wrap",
          "items": [ "mqtt.topicPrefix" ] 
        },
        {
          "type": "section",
          "title": "Select message format(s):",
          "expandable": false,
          "expanded": true,
          "items": [
            "mqtt.formatHomeAssistant",
            "mqtt.formatConnection",
            "mqtt.formatFault"
          ]
        },
        {
          "type": "section",
          "title": "Select publish event(s):",
          "expandable": false,
          "expanded": true,
          "items": [
            "mqtt.publishStatusChanged",
            "mqtt.publishIntervals",
            "mqtt.publishFrequency",
            "mqtt.publishAll",
            "mqtt.showMqttEvents"
          ]
        },
        {
          "type": "section",
          "title": "Current Temperature Subscription",
          "expandable": true,
          "expanded": false,
          "items": [
            {
              "type": "flex",
              "flex-flow": "row wrap",
              "items": [ "mqtt.subscribeTemperature.U", "mqtt.subscribeTemperature.jsonPathU" ] 
            },
            {
              "type": "flex",
              "flex-flow": "row wrap",
              "items": [ "mqtt.subscribeTemperature.A", "mqtt.subscribeTemperature.jsonPathA" ] 
            },
            {
              "type": "flex",
              "flex-flow": "row wrap",
              "items": [ "mqtt.subscribeTemperature.B", "mqtt.subscribeTemperature.jsonPathB" ] 
            },
            {
              "type": "flex",
              "flex-flow": "row wrap",
              "items": [ "mqtt.subscribeTemperature.C", "mqtt.subscribeTemperature.jsonPathC" ] 
            },
            {
              "type": "flex",
              "flex-flow": "row wrap",
              "items": [ "mqtt.subscribeTemperature.D", "mqtt.subscribeTemperature.jsonPathD" ] 
            }
          ]
        }
      ]
    },
    {
      "type": "fieldset",
      "title": "Pushover Notifications",
      "expandable": true,
      "expanded": false,
      "items": [
        "pushover.token",
        {
          "type": "array",
          "orderable": false,
          "buttonText": "Add User Key",
          "items": [
            {
              "type": "flex",
              "flex-row": "row wrap",
              "items": [ "pushover.users[]" ]
            }
          ]
        },
        "pushover.minTemperatureThreshold",
        "pushover.maxTemperatureThreshold",
        "pushover.connectionError",
        "pushover.faultDetected",
        "pushover.dayIncorrect",
        "pushover.timeIncorrect"
      ]
    },
    {
      "type": "fieldset",
      "title": "Other Settings",
      "expandable": true,
      "expanded": false,
      "items": [
        "showHomebridgeEvents",
        "showModuleEvents",
        "showModuleStatus",
        "clearCache",
        "forceAutoDiscovery",
        {
          "type": "flex",
          "flex-flow": "row wrap",
          "items": [ "bootTime", "bootPassword" ] 
        }
      ]
    }
  ]
}