{
  "pluginAlias": "OmniLinkPlatform",
  "pluginType": "platform",
  "singular": false,
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "title": "Name",
        "type": "string",
        "required": true,
        "default": "Omni"
      },
      "address": {
        "title": "IP Address",
        "type": "string",
        "format": "ipv4",
        "required": true
      },
      "port": {
        "title": "Port",
        "type": "number",
        "required": true,
        "default": 4369,
        "minimum": 0,
        "maximum": 65535
      },
      "key1": {
        "title": "Key 1",
        "type": "string",
        "placeholder": "00-00-00-00-00-00-00-00",
        "pattern": "^([A-Fa-f0-9]{2}-){7}[A-Fa-f0-9]{2}$",
        "required": true
      },
      "key2": {
        "title": "Key 2",
        "type": "string",
        "placeholder": "00-00-00-00-00-00-00-00",
        "pattern": "^([A-Fa-f0-9]{2}-){7}[A-Fa-f0-9]{2}$",
        "required": true
      },
      "includeAreas": {
        "title": "Include Areas (shown as Security System accessories)",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "includeZones": {
        "title": "Include Zones (shown as Sensor accessories)",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "includeBypassZones": {
        "title": "Include Bypass Zones (shown as Switch accessories)",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "includeButtons": {
        "title": "Include Buttons (shown as Switch accessories)",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "includeUnits": {
        "title": "Include Units (shown as Switch, Lightbulb or Window Covering accessories)",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "includeThermostats": {
        "title": "Include Thermostats (shown as Thermostat accessories)",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "includeEmergencyAlarms": {
        "title": "Include Emergency Alarms (shown as Switch accessories)",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "includeAccessControls": {
        "title": "Include Access Controls (shown as Lock Mechanism accessories)",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "includeAuxiliarySensors": {
        "title": "Include Auxiliary Sensors (shown as Temperature or Humidity Sensor accessories)",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "setHomeToAway": {
        "title": "Set Home mode to Away mode",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "setNightToAway": {
        "title": "Set Night mode to Away mode",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "securityCode": {
        "title": "Security Code",
        "description": "4 digit code to arm/disarm security system",
        "type": "string",
        "minLength": 4,
        "maxLength": 4,
        "placeholder": "0000",
        "pattern": "^[0-9]{4}$",
        "required": false
      },
      "includeHoldStatusSwitches": {
        "title": "Include Hold Status Switches",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "includeFanModeSwitches": {
        "title": "Include Fan Mode Switches",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "includeHumidityControls": {
        "title": "Include Humidity Controls",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "targetHumiditySetPointType": {
        "title": "Target Humidity Set Point Type",
        "description": "The set point type of Omni's thermostat that will be associated to the HomeKit Target Humidity",
        "type": "integer",
        "default": 1,
        "required": true,
        "oneOf": [
          { "title": "Humidify Set Point", "enum": [ 1 ] },
          { "title": "Dehumidify Set Point", "enum": [ 2 ] }
        ]
      },
      "targetHumidityDifference": {
        "title": "Target Humidity Difference (%)",
        "description": "Difference between the Humidify and Dehumidify set points (0 = don't modify set point)",
        "type": "number",
        "default": 0,
        "required": false,
        "minimum": 0,
        "maximum": 100
      },
      "minTemperature": {
        "title": "Minimum allowed temperature (in Celcius)",
        "type": "number",
        "default": 0,
        "required": false,
        "minimum": -40,
        "maximum": 87.5
      },
      "maxTemperature": {
        "title": "Maximum allowed temperature (in Celcius)",
        "type": "number",
        "default": 40,
        "required": false,
        "minimum": -40,
        "maximum": 87.5
      },
      "defaultAccessoryMappings": {
        "type": "object",
        "properties": {
          "zone": {
            "title": "Zone",
            "type": "string",
            "required": true,
            "default": "motion",
            "oneOf": [
              { "title": "Motion Sensor", "enum": [ "motion" ] },
              { "title": "Smoke Sensor", "enum": [ "smoke" ] },
              { "title": "Contact Sensor", "enum": [ "contact" ] },
              { "title": "Carbon Dioxide Sensor", "enum": [ "carbondioxide" ] },
              { "title": "Carbon Monoxide Sensor", "enum": [ "carbonmonoxide" ] },
              { "title": "Leak Sensor", "enum": [ "leak" ] },
              { "title": "Occupancy Sensor", "enum": [ "occupancy" ] },
              { "title": "None", "enum": [ "none" ] }
            ]
          },
          "zoneFireEmergency": {
            "title": "Zone (Fire Emergency)",
            "type": "string",
            "required": true,
            "default": "smoke",
            "oneOf": [
              { "title": "Motion Sensor", "enum": [ "motion" ] },
              { "title": "Smoke Sensor", "enum": [ "smoke" ] },
              { "title": "Contact Sensor", "enum": [ "contact" ] },
              { "title": "Carbon Dioxide Sensor", "enum": [ "carbondioxide" ] },
              { "title": "Carbon Monoxide Sensor", "enum": [ "carbonmonoxide" ] },
              { "title": "Leak Sensor", "enum": [ "leak" ] },
              { "title": "Occupancy Sensor", "enum": [ "occupancy" ] },
              { "title": "None", "enum": [ "none" ] }
            ]
          },
          "unit": {
            "title": "Unit",
            "type": "string",
            "required": true,
            "default": "switch",
            "oneOf": [
              { "title": "Switch", "enum": [ "switch" ] },
              { "title": "Lightbulb", "enum": [ "lightbulb" ] },
              { "title": "Window Covering", "enum": [ "windowcovering" ]},
              { "title": "None", "enum": [ "none" ] }
            ]
          }
        }
      },
      "map": {
        "type": "object",
        "properties": {
          "zones": {
            "type": "object",
            "properties": {
              "motion": {
                "title": "Motion Sensors",
                "description": "comma seperated list of zone numbers to be mapped to motion sensors",
                "type": "string",
                "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
              },
              "smoke": {
                "title": "Smoke Sensors",
                "description": "comma seperated list of zone numbers to be mapped to smoke sensors",
                "type": "string",
                "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
              },
              "contact": {
                "title": "Contact Sensors",
                "description": "comma seperated list of zone numbers to be mapped to contact sensors",
                "type": "string",
                "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
              },
              "carbondioxide": {
                "title": "Carbon Dioxide Sensors",
                "description": "comma seperated list of zone numbers to be mapped to carbon dioxide sensors",
                "type": "string",
                "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
              },
              "carbonmonoxide": {
                "title": "Carbon Monoxide Sensors",
                "description": "comma seperated list of zone numbers to be mapped to carbon monoxide sensors",
                "type": "string",
                "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
              },
              "leak": {
                "title": "Leak Sensors",
                "description": "comma seperated list of zone numbers to be mapped to leak sensors",
                "type": "string",
                "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
              },
              "occupancy": {
                "title": "Occupancy Sensors",
                "description": "comma seperated list of zone numbers to be mapped to occupancy sensors",
                "type": "string",
                "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
              }
            }
          },
          "units": {
            "type": "object",
            "properties": {
              "switch": {
                "title": "Switches",
                "description": "comma seperated list of unit numbers to be mapped to switches",
                "type": "string",
                "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
              },
              "lightbulb": {
                "title": "Lightbulbs",
                "description": "comma seperated list of unit numbers to be mapped to lightbulbs",
                "type": "string",
                "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
              },
              "windowcovering": {
                "title": "Window Coverings",
                "description": "comma seperated list of unit numbers to be mapped to window coverings",
                "type": "string",
                "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
              }
            }
          }
        }
      },
      "exclude": {
        "type": "object",
        "properties": {
          "areas": {
            "title": "Areas",
            "description": "comma seperated list of area numbers",
            "type": "string",
            "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
          },
          "zones": {
            "title": "Zones",
            "description": "comma seperated list of zone numbers",
            "type": "string",
            "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
          },
          "units": {
            "title": "Units",
            "description": "comma seperated list of unit numbers",
            "type": "string",
            "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
          },
          "buttons": {
            "title": "Buttons",
            "description": "comma seperated list of button numbers",
            "type": "string",
            "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
          },
          "thermostats": {
            "title": "Thermostats",
            "description": "comma seperated list of thermostat numbers",
            "type": "string",
            "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
          },
          "auxiliarySensors": {
            "title": "Auxiliary Sensors",
            "description": "comma seperated list of auxiliary sensor numbers",
            "type": "string",
            "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
          },
          "accessControls": {
            "title": "Access Controls",
            "description": "comma seperated list of access control numbers",
            "type": "string",
            "pattern": "^[0-9]{1,3}(,[0-9]{1,3})*$"
          }
        }
      },
      "garageDoors": {
        "title": "Garage Doors",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "buttonId": {
              "title": "Button Number",
              "type": "number",
              "minimum": 1,
              "maximum": 200,
              "required": true
            },
            "zoneId": {
              "title": "Zone Number",
              "type": "number",
              "minimum": 1,
              "maximum": 200,
              "required": true
            },
            "openTime": {
              "title": "Time taken to open (secs)",
              "type": "number",
              "minimum": 1,
              "maximum": 60,
              "required": true
            }
          }
        }
      },
      "pushover": {
        "type": "object",
        "properties": {
          "token": {
            "title": "Application Token",
            "type": "string",
            "required": false
          },
          "users": {
            "title": "User Keys",
            "type": "array",
            "items": {
              "title": "User Key",
              "type": "string"
            }
          },
          "alarms": {
            "type": "object",
            "properties": {
              "burglary": {
                "type": "boolean",
                "default": false,
                "required": false
              },
              "fire": {
                "type": "boolean",
                "default": false,
                "required": false
              },
              "gas": {
                "type": "boolean",
                "default": false,
                "required": false
              },
              "auxiliary": {
                "type": "boolean",
                "default": false,
                "required": false
              },
              "freeze": {
                "type": "boolean",
                "default": false,
                "required": false
              },
              "water": {
                "type": "boolean",
                "default": false,
                "required": false
              },
              "duress": {
                "type": "boolean",
                "default": false,
                "required": false
              },
              "temperature": {
                "type": "boolean",
                "default": false,
                "required": false
              }
            }
          },
          "troubles": {
            "type": "object",
            "properties": {
              "freeze": {
                "type": "boolean",
                "default": false,
                "required": false
              },
              "batterylow": {
                "title": "Battery Low",
                "type": "boolean",
                "default": false,
                "required": false
              },
              "acpower": {
                "title": "AC Power",
                "type": "boolean",
                "default": false,
                "required": false
              },
              "phoneline": {
                "title": "Phone Line",
                "type": "boolean",
                "default": false,
                "required": false
              },
              "digitalcommunicator": {
                "title": "Digital Communicator",
                "type": "boolean",
                "default": false,
                "required": false
              },
              "fuse": {
                "type": "boolean",
                "default": false,
                "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"
          },
          "showMqttEvents": {
            "title": "Show MQTT events in the log",
            "type": "boolean",
            "default": false,
            "required": false
          }
        }
      },
      "syncTime": {
        "title": "Sync date and time of controller with host",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "showHomebridgeEvents": {
        "title": "Show Homebridge events in the log",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "showOmniEvents": {
        "title": "Show Omni notification events in the log",
        "type": "boolean",
        "default": false,
        "required": false
      },
      "excludeZoneStatusChanges": {
        "title": "Exclude Zone Status changes from the log",
        "type": "boolean",
        "default": false,
        "required": false        
      },
      "excludeTemperatureChanges": {
        "title": "Exclude Temperature and Humidity changes from the log",
        "type": "boolean",
        "default": false,
        "required": false           
      },
      "showRequestResponse": {
        "title": "Show Requests and Responses 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
      },
      "refreshStatusesInterval": {
        "title": "Refresh Statuses Interval (secs)",
        "type": "number",
        "default": 60,
        "minimum": 1,
        "maximum": 60,
        "required": false
      }      
    }
  },
  "layout": [
    "name",
    {
      "type": "flex",
      "flex-flow": "row wrap",
      "items": [ "address", "port" ]
    },
    {
      "type": "flex",
      "flex-flow": "row wrap",
      "items": [ "key1", "key2" ]
    },
    {
      "type": "fieldset",
      "title": "Accessory Settings",
      "expandable": true,
      "expanded": false,
      "items": [
        "includeAreas",
        "includeZones",
        "includeBypassZones",
        "includeButtons",
        "includeUnits",
        "includeThermostats",
        "includeEmergencyAlarms",
        "includeAccessControls",
        "includeAuxiliarySensors",
        {
          "type": "section",
          "title": "Security Settings",
          "expandable": true,
          "expanded": false,
          "items": [
            "setHomeToAway",
            "setNightToAway",
            "securityCode"
          ]
        },
        {
          "type": "section",
          "title": "Default Accessory Mappings (Zones & Units)",
          "expandable": true,
          "expanded": false,
          "items": [
            "defaultAccessoryMappings.zone",
            "defaultAccessoryMappings.zoneFireEmergency",
            "defaultAccessoryMappings.unit"
          ]
        },
        {
          "type": "section",
          "title": "Zone Accessory Mappings",
          "expandable": true,
          "expanded": false,
          "items": [
            "map.zones.motion",
            "map.zones.smoke",
            "map.zones.contact",
            "map.zones.carbondioxide",
            "map.zones.carbonmonoxide",
            "map.zones.leak",
            "map.zones.occupancy"
          ]
        },
        {
          "type": "section",
          "title": "Unit Accessory Mappings",
          "expandable": true,
          "expanded": false,
          "items": [
            "map.units.switch",
            "map.units.lightbulb",
            "map.units.windowcovering"
          ]
        },
        {
          "type": "section",
          "title": "Exclusions",
          "expandable": true,
          "expanded": false,
          "items": [
            "exclude.areas",
            "exclude.zones",
            "exclude.units",
            "exclude.buttons",
            "exclude.thermostats",
            "exclude.auxiliarySensors",
            "exclude.accessControls"
          ]
        },
        {
          "type": "section",
          "title": "Garage Door Opener Settings",
          "expandable": true,
          "expanded": false,
          "items": [
            {
              "type": "array",
              "orderable": false,
              "buttonText": "Add Garage Door",
              "items": [
                {
                  "type": "flex",
                  "flex-flow": "row wrap",
                  "items": [
                    "garageDoors[].buttonId",
                    "garageDoors[].zoneId",
                    "garageDoors[].openTime"
                  ]
                }
              ]
            }
          ]
        },
        {
          "type": "section",
          "title": "Thermostat Settings",
          "expandable": true,
          "expanded": false,
          "items": [
            {
              "type": "flex",
              "flex-flow": "row wrap",
              "items": [
                "minTemperature",
                "maxTemperature"
              ]
            },
            "includeHoldStatusSwitches",
            "includeFanModeSwitches",
            "includeHumidityControls",
            "targetHumiditySetPointType",
            "targetHumidityDifference"
          ]
        }
      ]
    },
    {
      "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[]" ]
            }
          ]
        },
        {
          "type": "section",
          "title": "Send notification for the following alarms:",
          "expandable": false,
          "expanded": true,
          "items": [
            "pushover.alarms.burglary",
            "pushover.alarms.fire",
            "pushover.alarms.gas",
            "pushover.alarms.auxiliary",
            "pushover.alarms.freeze",
            "pushover.alarms.water",
            "pushover.alarms.duress",
            "pushover.alarms.temperature"
          ]
        },
        {
          "type": "section",
          "title": "Send notification for the following troubles:",
          "expandable": false,
          "expanded": true,
          "items": [
            "pushover.troubles.freeze",
            "pushover.troubles.batterylow",
            "pushover.troubles.acpower",
            "pushover.troubles.phoneline",
            "pushover.troubles.digitalcommunicator",
            "pushover.troubles.fuse"
          ]
        }
      ]
    },
    {
      "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": "flex",
          "flex-flow": "row wrap",
          "items": [ "mqtt.showMqttEvents" ] 
        }
      ]
    },
    {
      "type": "fieldset",
      "title": "Other Settings",
      "expandable": true,
      "expanded": false,
      "items": [
        "syncTime",
        "showHomebridgeEvents",
        "showOmniEvents",
        "excludeZoneStatusChanges",
        "excludeTemperatureChanges",
        "showRequestResponse",
        "clearCache",
        "forceAutoDiscovery",
        "refreshStatusesInterval"
      ]
    }
  ]
}