{
  "pluginAlias": "eWeLink",
  "pluginType": "platform",
  "singular": true,
  "customUi": true,
  "customUiPath": "./lib/homebridge-ui",
  "headerDisplay": "<p align=\"center\"><img width=\"60%\" src=\"https://user-images.githubusercontent.com/43026681/101325266-63126600-3863-11eb-9382-4a2924f0e540.png\"></p><p align=\"center\">For help and support please visit our <a href=\"https://github.com/bwp91/homebridge-ewelink/wiki\">GitHub Wiki</a>. We hope you find this plugin useful!</p>",
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "type": "string",
        "title": "Plugin Name",
        "default": "eWeLink"
      },
      "username": {
        "type": "string",
        "title": "Username",
        "required": true,
        "placeholder": "Email or full phone (e.g. +8613185260282)",
        "description": "Your eWeLink username, please use your main eWeLink credentials (not a secondary/shared account)."
      },
      "password": {
        "type": "string",
        "title": "Password",
        "required": true,
        "description": "Your eWeLink password, can also be a base64 encoded version of your password."
      },
      "mode": {
        "type": "string",
        "title": "Connection Mode",
        "description": "This setting defines how the plugin communicates with your devices. For further guidance, please refer to <a href=\"https://github.com/bwp91/homebridge-ewelink/wiki/Connection-Methods\" target=\"_blank\">this wiki article</a>.",
        "default": "auto",
        "oneOf": [
          {
            "title": "Hybrid (Recommended)",
            "enum": ["auto"]
          },
          {
            "title": "Cloud Only",
            "enum": ["wan"]
          },
          {
            "title": "LAN Only (will remove unsupported devices)",
            "enum": ["lan"]
          }
        ]
      },
      "language": {
        "type": "string",
        "title": "Logging Language",
        "description": "Language to use for logging.",
        "default": "en",
        "oneOf": [
          {
            "title": "English",
            "enum": ["en"]
          },
          {
            "title": "French",
            "enum": ["fr"]
          },
          {
            "title": "Thai",
            "enum": ["th"]
          }
        ]
      },
      "disableDeviceLogging": {
        "type": "boolean",
        "title": "Disable Device Logging",
        "description": "Global logging setting for accessory status changes. If true then accessory status changes will not be logged. This can also be set per accessory later in the config."
      },
      "disableNoResponse": {
        "type": "boolean",
        "title": "Disable 'No Response'",
        "description": "If true, devices marked as cloud-offline will not be shown as 'No Response' in HomeKit.",
        "condition": {
          "functionBody": "return (model.mode !== 'lan');"
        }
      },
      "ignoredHomes": {
        "title": "Ignored Homes",
        "type": "string",
        "description": "A list of comma-separated eWeLink home ids to ignore.",
        "placeholder": ""
      },
      "countryCode": {
        "title": "Country Code",
        "type": "string",
        "description": "Override the default country code, may help with login issues for users in other regions.",
        "placeholder": "+44"
      },
      "appId": {
        "title": "App ID",
        "type": "string",
        "description": "Available if you want to override the eWeLink App ID."
      },
      "appSecret": {
        "title": "App Secret",
        "type": "string",
        "description": "Available if you want to override the eWeLink App Secret."
      },
      "httpHost": {
        "title": "HTTP Host",
        "type": "string",
        "description": "Available if you want to override the API host.",
        "placeholder": "eu-apia.coolkit.cc",
        "oneOf": [
          {
            "title": "Auto (Recommended)",
            "enum": ["auto"]
          },
          {
            "title": "eu-apia.coolkit.cc",
            "enum": ["eu-apia.coolkit.cc"]
          },
          {
            "title": "us-apia.coolkit.cc",
            "enum": ["us-apia.coolkit.cc"]
          },
          {
            "title": "as-apia.coolkit.cc",
            "enum": ["as-apia.coolkit.cc"]
          },
          {
            "title": "cn-apia.coolkit.cn",
            "enum": ["cn-apia.coolkit.cn"]
          }
        ]
      },
      "apiPort": {
        "type": "integer",
        "title": "Internal API Port",
        "description": "Port to use for the internal HTTP API. Set to 0 to disable. Set to 1 to choose a randomly available port.",
        "minimum": 0
      },
      "singleDevices": {
        "title": "Single Channel Devices",
        "description": "Optional settings for single-channel switch, outlet and light switch devices.",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "label": {
              "title": "Label",
              "type": "string",
              "description": "This setting has no effect except to help identify this device."
            },
            "deviceId": {
              "type": "string",
              "title": "Device ID",
              "description": "Enter the 10 digit eWeLink Device ID to begin.",
              "minLength": 10,
              "maxLength": 10
            },
            "ignoreDevice": {
              "type": "boolean",
              "title": "Hide From HomeKit",
              "description": "If true, this accessory will be removed and ignored from HomeKit.",
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && model.singleDevices[arrayIndices].deviceId && model.singleDevices[arrayIndices].deviceId.length === 10);"
              }
            },
            "deviceModel": {
              "type": "string",
              "title": "Device Model",
              "description": "This setting has no effect except showing the relevant options for this model below.",
              "oneOf": [
                {
                  "title": "Sonoff BASIC/MINI/RF/SV/RE5V1C",
                  "enum": ["single"]
                },
                {
                  "title": "Sonoff T1/T2/T3/TX-1C/M5-1-Gang",
                  "enum": ["t"]
                },
                {
                  "title": "Sonoff POW/R2",
                  "enum": ["pow"]
                },
                {
                  "title": "Sonoff IW100/IW101",
                  "enum": ["iw"]
                },
                {
                  "title": "Sonoff S20/S26/S31/S55",
                  "enum": ["s"]
                },
                {
                  "title": "Sonoff Micro",
                  "enum": ["micro"]
                },
                {
                  "title": "Sonoff SLAMPHER/R2",
                  "enum": ["slampher"]
                },
                {
                  "title": "Eachen GD-DC5",
                  "enum": ["gddc5"]
                },
                {
                  "title": "KingArt KING-Q1/Q4",
                  "enum": ["king"]
                },
                {
                  "title": "Zigbee Single Channel (BASICZBR3/ZBMINI/S31ZB)",
                  "enum": ["zb"]
                }
              ],
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && model.singleDevices[arrayIndices].deviceId && model.singleDevices[arrayIndices].deviceId.length === 10 && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "showAs": {
              "type": "string",
              "title": "Show As (Simulation)",
              "description": "Expose this device as a different HomeKit accessory type.",
              "oneOf": [
                {
                  "title": "1 Switch (Default)",
                  "enum": ["default"]
                },
                {
                  "title": "1 Outlet",
                  "enum": ["outlet"]
                },
                {
                  "title": "1 Air Purifier",
                  "enum": ["purifier"]
                },
                {
                  "title": "1 Heater",
                  "enum": ["heater"]
                },
                {
                  "title": "1 Cooler",
                  "enum": ["cooler"]
                },
                {
                  "title": "1 Doorbell",
                  "enum": ["doorbell"]
                },
                {
                  "title": "1 Garage Door",
                  "enum": ["garage"]
                },
                {
                  "title": "1 Gate (As Garage Door)",
                  "enum": ["gate"]
                },
                {
                  "title": "1 Irrigation Valve",
                  "enum": ["valve"]
                },
                {
                  "title": "1 Lock",
                  "enum": ["lock"]
                },
                {
                  "title": "1 Programmable Button",
                  "enum": ["p_button"]
                },
                {
                  "title": "1 Sensor",
                  "enum": ["sensor"]
                },
                {
                  "title": "1 Tap/Faucet",
                  "enum": ["tap"]
                },
                {
                  "title": "1 Audio Receiver (External Accessory)",
                  "enum": ["audio"]
                },
                {
                  "title": "1 Set Top Box (External Accessory)",
                  "enum": ["box"]
                },
                {
                  "title": "1 Streaming Stick (External Accessory)",
                  "enum": ["stick"]
                }
              ],
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && ['single', 't', 'pow', 'iw', 's', 'micro', 'slampher', 'zb'].includes(model.singleDevices[arrayIndices].deviceModel) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "showAsMotor": {
              "type": "string",
              "title": "KingArt KING-Q1/Q4 Accessory Type",
              "description": "Select the accessory type to show in HomeKit.",
              "oneOf": [
                {
                  "title": "Window Blind/Covering (Default)",
                  "enum": ["blind"]
                },
                {
                  "title": "Door",
                  "enum": ["door"]
                },
                {
                  "title": "Garage Door",
                  "enum": ["garage"]
                },
                {
                  "title": "Window",
                  "enum": ["window"]
                }
              ],
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && model.singleDevices[arrayIndices].deviceId && ['king'].includes(model.singleDevices[arrayIndices].deviceModel) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "showAsEachen": {
              "type": "string",
              "title": "Garage Device Accessory Type",
              "description": "Select the accessory type to show in HomeKit.",
              "oneOf": [
                {
                  "title": "Garage Door (Default)",
                  "enum": ["garage"]
                },
                {
                  "title": "Lock",
                  "enum": ["lock"]
                }
              ],
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && model.singleDevices[arrayIndices].deviceId && ['gddc5'].includes(model.singleDevices[arrayIndices].deviceModel) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "inUsePowerThreshold": {
              "type": "integer",
              "title": "Outlet 'In Use' Threshold",
              "description": "HomeKit will set the 'In Use' status of outlet devices to true when the wattage is above this number. Must be 0 or more.",
              "placeholder": 0,
              "minimum": 0,
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && ['pow', 'iw'].includes(model.singleDevices[arrayIndices].deviceModel) && [undefined, 'default', 'outlet'].includes(model.singleDevices[arrayIndices].showAs) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "disableTimer": {
              "type": "boolean",
              "title": "Disable Valve Timer",
              "description": "If true, the timer for the valve will be removed.",
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && ['valve'].includes(model.singleDevices[arrayIndices].showAs) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "temperatureSource": {
              "type": "string",
              "title": "Temperature Sensor ID",
              "description": "Enter a eWeLink, Govee or Meross device ID which provides a current temperature reading.",
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && ['heater', 'cooler'].includes(model.singleDevices[arrayIndices].showAs) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "isInched": {
              "type": "boolean",
              "title": "Status By Inching",
              "description": "If true, the plugin will show the on/off status based on inching mode.",
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && [undefined, 'default', 'outlet'].includes(model.singleDevices[arrayIndices].showAs) && !['king', 'gddc5'].includes(model.singleDevices[arrayIndices].deviceModel) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "sensorType": {
              "type": "string",
              "title": "Sensor Type",
              "description": "The type of sensor to use.",
              "oneOf": [
                {
                  "title": "Motion (Default)",
                  "enum": ["motion"]
                },
                {
                  "title": "Smoke/Fire",
                  "enum": ["smoke"]
                },
                {
                  "title": "Water/Leak",
                  "enum": ["water"]
                },
                {
                  "title": "Carbon Monoxide",
                  "enum": ["co"]
                },
                {
                  "title": "Carbon Dioxide",
                  "enum": ["co2"]
                },
                {
                  "title": "Occupancy",
                  "enum": ["occupancy"]
                },
                {
                  "title": "Contact",
                  "enum": ["contact"]
                }
              ],
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && ['sensor'].includes(model.singleDevices[arrayIndices].showAs) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "operationTime": {
              "type": "integer",
              "title": "Operation Time (Deciseconds)",
              "description": "Garage doors: the time to open/close the device. Locks: the time to show as unlocked. This setting is in deciseconds - count the time in seconds and multiply by 10, for example 75 for 7.5 seconds. Must be 20 or more.",
              "placeholder": 100,
              "minimum": 20,
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && ((model.singleDevices[arrayIndices].deviceModel === 'gddc5' && model.singleDevices[arrayIndices].showAsEachen !== 'lock') || ['garage', 'lock', 'gate'].includes(model.singleDevices[arrayIndices].showAs)) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "operationTimeDown": {
              "type": "integer",
              "title": "Operation Time Down (Deciseconds)",
              "description": "If your garage door has a different operation time for up and down, use this setting to specify the operation time DOWN (in deciseconds) and the other setting to specify the operation time UP. Otherwise leave blank. Must be 20 or more.",
              "placeholder": 100,
              "minimum": 20,
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && ['garage'].includes(model.singleDevices[arrayIndices].showAs) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "sensorId": {
              "type": "string",
              "title": "Sensor",
              "description": "A DW2 or Zigbee contact sensor can be used for a single garage door or lock to determine the current state. Enter the 10 digit eWeLink Device ID (normally in the format 1000ab23cd). Otherwise leave blank.",
              "minLength": 10,
              "maxLength": 10,
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && ['garage', 'lock'].includes(model.singleDevices[arrayIndices].showAs) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "hideSensor": {
              "type": "boolean",
              "title": "Hide Sensor",
              "description": "Hide this contact sensor accessory from HomeKit.",
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && model.singleDevices[arrayIndices].sensorId && model.singleDevices[arrayIndices].sensorId.length === 10 && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "obstructId": {
              "type": "string",
              "title": "Obstruction Switch",
              "description": "An optional switch that will trigger the Obstruction Detected feature depending on its value. Otherwise leave blank.",
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && ((model.singleDevices[arrayIndices].deviceModel === 'gddc5' && model.singleDevices[arrayIndices].showAsEachen !== 'lock') || ['garage'].includes(model.singleDevices[arrayIndices].showAs)) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            },
            "ipAddress": {
              "type": "string",
              "title": "IP Address",
              "description": "You can manually set the IP address for this device if it cannot be discovered by the plugin.",
              "condition": {
                "functionBody": "return (model.singleDevices && model.singleDevices[arrayIndices] && ['single', 't', 'pow', 'iw', 's', 'micro', 'slampher', 'gddc5'].includes(model.singleDevices[arrayIndices].deviceModel) && !model.singleDevices[arrayIndices].ignoreDevice);"
              }
            }
          }
        }
      },
      "multiDevices": {
        "title": "Multi Channel Devices",
        "description": "Optional settings for multi-channel switch, outlet and light switch devices.",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "label": {
              "title": "Label",
              "type": "string",
              "description": "This setting has no effect except to help identify this device."
            },
            "deviceId": {
              "type": "string",
              "title": "Device ID",
              "description": "Enter the 10 digit eWeLink Device ID to begin.",
              "minLength": 10,
              "maxLength": 10
            },
            "ignoreDevice": {
              "type": "boolean",
              "title": "Hide From HomeKit",
              "description": "If true, this accessory will be removed and ignored from HomeKit.",
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && model.multiDevices[arrayIndices].deviceId && model.multiDevices[arrayIndices].deviceId.length === 10);"
              }
            },
            "deviceModel": {
              "type": "string",
              "title": "Device Model",
              "description": "This setting has no effect except showing the relevant options for this model below.",
              "oneOf": [
                {
                  "title": "Sonoff DUAL/R2",
                  "enum": ["dual_dualr2"]
                },
                {
                  "title": "Sonoff DUALR3 (Switch Mode)",
                  "enum": ["dualr3_switch"]
                },
                {
                  "title": "Sonoff DUALR3 (Motor Mode)",
                  "enum": ["dualr3_motor"]
                },
                {
                  "title": "Sonoff 4CH/PRO/R2/R3",
                  "enum": ["4ch"]
                },
                {
                  "title": "Sonoff T1/T2/T3/TX-2C/3C/4C/M5-2/3-Gang",
                  "enum": ["t"]
                },
                {
                  "title": "Zigbee Multi Channel",
                  "enum": ["zb"]
                }
              ],
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && model.multiDevices[arrayIndices].deviceId && model.multiDevices[arrayIndices].deviceId.length === 10 && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "showAs": {
              "type": "string",
              "title": "Show As (Simulation)",
              "description": "Expose this device as a different HomeKit accessory type.",
              "oneOf": [
                {
                  "title": "Switches (Default)",
                  "enum": ["default"]
                },
                {
                  "title": "Outlets",
                  "enum": ["outlet"]
                },
                {
                  "title": "1 Air Purifier",
                  "enum": ["purifier"]
                },
                {
                  "title": "1 Door",
                  "enum": ["door"]
                },
                {
                  "title": "1 Doorbell",
                  "enum": ["doorbell"]
                },
                {
                  "title": "1 Garage Door",
                  "enum": ["garage"]
                },
                {
                  "title": "2 Garage Doors",
                  "enum": ["garage_two"]
                },
                {
                  "title": "4 Garage Doors",
                  "enum": ["garage_four"]
                },
                {
                  "title": "1 Gate (As Garage Door)",
                  "enum": ["gate"]
                },
                {
                  "title": "1 Irrigation Valve",
                  "enum": ["valve"]
                },
                {
                  "title": "2 Irrigation Valves",
                  "enum": ["valve_two"]
                },
                {
                  "title": "4 Irrigation Valves",
                  "enum": ["valve_four"]
                },
                {
                  "title": "1 Lock",
                  "enum": ["lock"]
                },
                {
                  "title": "1 Programmable Button",
                  "enum": ["p_button"]
                },
                {
                  "title": "1 Sensor",
                  "enum": ["sensor"]
                },
                {
                  "title": "1 Switch & 1 Valve",
                  "enum": ["switch_valve"]
                },
                {
                  "title": "1 Tap/Faucet",
                  "enum": ["tap"]
                },
                {
                  "title": "2 Taps/Faucets",
                  "enum": ["tap_two"]
                },
                {
                  "title": "1 Window",
                  "enum": ["window"]
                },
                {
                  "title": "1 Window Blind/Covering",
                  "enum": ["blind"]
                },
                {
                  "title": "1 Audio Receiver (External Accessory)",
                  "enum": ["audio"]
                },
                {
                  "title": "1 Set Top Box (External Accessory)",
                  "enum": ["box"]
                },
                {
                  "title": "1 Streaming Stick (External Accessory)",
                  "enum": ["stick"]
                }
              ],
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && model.multiDevices[arrayIndices].deviceId && ['dual_dualr2', 'dualr3_switch', '4ch', 't', 'zb'].includes(model.multiDevices[arrayIndices].deviceModel) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "showAsMotor": {
              "type": "string",
              "title": "DUALR3 Accessory Type",
              "description": "Select the accessory type to show in HomeKit.",
              "oneOf": [
                {
                  "title": "Window Blind/Covering (Default)",
                  "enum": ["blind"]
                },
                {
                  "title": "Door",
                  "enum": ["door"]
                },
                {
                  "title": "Garage Door",
                  "enum": ["garage"]
                },
                {
                  "title": "Window",
                  "enum": ["window"]
                }
              ],
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && model.multiDevices[arrayIndices].deviceId && ['dualr3_motor'].includes(model.multiDevices[arrayIndices].deviceModel) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "hideChannels": {
              "type": "string",
              "title": "Hide Channels",
              "description": "A comma separated list of channels to hide for this device. For example '0' or '0,1,2'.",
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && model.multiDevices[arrayIndices].deviceId && ['dual_dualr2', 'dualr3_switch', '4ch', 't', 'zb'].includes(model.multiDevices[arrayIndices].deviceModel) && [undefined, 'default', 'outlet'].includes(model.multiDevices[arrayIndices].showAs) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "inUsePowerThreshold": {
              "type": "integer",
              "title": "Outlet 'In Use' Threshold",
              "description": "HomeKit will set the 'In Use' status of outlet devices to true when the wattage is above this number. Must be 0 or more.",
              "placeholder": 0,
              "minimum": 0,
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && model.multiDevices[arrayIndices].deviceId && [undefined, 'default', 'outlet'].includes(model.multiDevices[arrayIndices].showAs) && ['dualr3_switch'].includes(model.multiDevices[arrayIndices].deviceModel) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "disableTimer": {
              "type": "boolean",
              "title": "Disable Valve Timer",
              "description": "If true, the timer for the valve will be removed.",
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && ['valve', 'valve_two', 'valve_four'].includes(model.multiDevices[arrayIndices].showAs) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "inchChannels": {
              "type": "string",
              "title": "Status By Inching",
              "description": "A comma separated list of channels to show the on/off status based on inching mode. For example '1,2'.",
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && ['dual_dualr2', 'dualr3_switch', '4ch', 't', 'zb'].includes(model.multiDevices[arrayIndices].deviceModel) && [undefined, 'default', 'outlet'].includes(model.multiDevices[arrayIndices].showAs) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "sensorType": {
              "type": "string",
              "title": "Sensor Type",
              "description": "The type of sensor to use.",
              "oneOf": [
                {
                  "title": "Motion (Default)",
                  "enum": ["motion"]
                },
                {
                  "title": "Smoke/Fire",
                  "enum": ["smoke"]
                },
                {
                  "title": "Water/Leak",
                  "enum": ["water"]
                },
                {
                  "title": "Carbon Monoxide",
                  "enum": ["co"]
                },
                {
                  "title": "Carbon Dioxide",
                  "enum": ["co2"]
                },
                {
                  "title": "Occupancy",
                  "enum": ["occupancy"]
                },
                {
                  "title": "Contact",
                  "enum": ["contact"]
                }
              ],
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && ['sensor'].includes(model.multiDevices[arrayIndices].showAs) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "operationTime": {
              "type": "integer",
              "title": "Operation Time (Deciseconds)",
              "description": "Blinds/garage doors: the time to open/close the device. Locks: the time to show as unlocked. This setting is in deciseconds - count the time in seconds and multiply by 10, for example 75 for 7.5 seconds. Must be 20 or more.",
              "placeholder": 100,
              "minimum": 20,
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && ['garage', 'garage_two', 'garage_four', 'blind', 'door', 'window', 'lock', 'gate'].includes(model.multiDevices[arrayIndices].showAs) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "operationTimeDown": {
              "type": "integer",
              "title": "Operation Time Down (Deciseconds)",
              "description": "If your garage door or blind has a different operation time for up and down, use this setting to specify the operation time DOWN (in deciseconds) and the other setting to specify the operation time UP. Otherwise leave blank. Must be 20 or more.",
              "placeholder": 100,
              "minimum": 20,
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && ['garage', 'garage_two', 'garage_four', 'blind', 'door', 'window'].includes(model.multiDevices[arrayIndices].showAs) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "sensorId": {
              "type": "string",
              "title": "Sensor",
              "description": "A DW2 or Zigbee contact sensor can be used for a single garage door or lock to determine the current state. Enter the 10 digit eWeLink Device ID (normally in the format 1000ab23cd). Otherwise leave blank.",
              "minLength": 10,
              "maxLength": 10,
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && ['garage', 'lock'].includes(model.multiDevices[arrayIndices].showAs) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "hideSensor": {
              "type": "boolean",
              "title": "Hide Sensor",
              "description": "Hide this contact sensor accessory from HomeKit.",
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && model.multiDevices[arrayIndices].sensorId && model.multiDevices[arrayIndices].sensorId.length === 10 && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "obstructId": {
              "type": "string",
              "title": "Obstruction Switch",
              "description": "An optional switch that will trigger the Obstruction Detected feature depending on its value. Otherwise leave blank.",
              "condition": {
                "functionBody": "return (model.multiDevices && model.multiDevices[arrayIndices] && ['garage'].includes(model.multiDevices[arrayIndices].showAs) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            },
            "ipAddress": {
              "type": "string",
              "title": "IP Address",
              "description": "You can manually set the IP address for this device if it cannot be discovered by the plugin.",
              "condition": {
                "functionBody": "return (model.mode !== 'wan' && model.multiDevices && model.multiDevices[arrayIndices] && model.multiDevices[arrayIndices].deviceId && ['dual_dualr2', 'dualr3_switch', 'dualr3_motor', '4ch', 't'].includes(model.multiDevices[arrayIndices].deviceModel) && !model.multiDevices[arrayIndices].ignoreDevice);"
              }
            }
          }
        }
      },
      "lightDevices": {
        "title": "Light Devices",
        "description": "Optional settings for dimmer, bulb and LED strip devices.",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "label": {
              "title": "Label",
              "type": "string",
              "description": "This setting has no effect except to help identify this device."
            },
            "deviceId": {
              "type": "string",
              "title": "Device ID",
              "description": "Enter the 10 digit eWeLink Device ID to begin.",
              "minLength": 10,
              "maxLength": 10
            },
            "ignoreDevice": {
              "type": "boolean",
              "title": "Hide From HomeKit",
              "description": "If true, this accessory will be removed and ignored from HomeKit.",
              "condition": {
                "functionBody": "return (model.lightDevices && model.lightDevices[arrayIndices] && model.lightDevices[arrayIndices].deviceId && model.lightDevices[arrayIndices].deviceId.length === 10);"
              }
            },
            "deviceModel": {
              "type": "string",
              "title": "Device Model",
              "description": "This setting has no effect except showing the relevant options for this model below.",
              "oneOf": [
                {
                  "title": "Sonoff D1/R2",
                  "enum": ["d1"]
                },
                {
                  "title": "Sonoff B1/R2",
                  "enum": ["b1"]
                },
                {
                  "title": "Sonoff L1/L2/Lite",
                  "enum": ["l1"]
                },
                {
                  "title": "Sonoff B02-B-A60",
                  "enum": ["bulbB02BA60"]
                },
                {
                  "title": "Sonoff B02-F-A60",
                  "enum": ["bulbB02FA60"]
                },
                {
                  "title": "Sonoff B02-F-ST64",
                  "enum": ["bulbB02FST64"]
                },
                {
                  "title": "Sonoff B05-B-A60",
                  "enum": ["bulbB05BA60"]
                },
                {
                  "title": "Sonoff B05-BL-A19",
                  "enum": ["bulbB05BLA19"]
                },
                {
                  "title": "KingArt KING-M4",
                  "enum": ["king"]
                },
                {
                  "title": "Zigbee Light (Dimmer)",
                  "enum": ["zl_d"]
                },
                {
                  "title": "Zigbee Light (Dimmer + CCT)",
                  "enum": ["zl_dc"]
                }
              ],
              "condition": {
                "functionBody": "return (model.lightDevices && model.lightDevices[arrayIndices] && model.lightDevices[arrayIndices].deviceId && model.lightDevices[arrayIndices].deviceId.length === 10 && !model.lightDevices[arrayIndices].ignoreDevice);"
              }
            },
            "showAs": {
              "type": "string",
              "title": "Show As (Simulation)",
              "description": "Expose this device as a different HomeKit accessory type.",
              "oneOf": [
                {
                  "title": "1 Light (Default)",
                  "enum": ["default"]
                },
                {
                  "title": "1 Fan",
                  "enum": ["fan"]
                }
              ],
              "condition": {
                "functionBody": "return (model.lightDevices && model.lightDevices[arrayIndices] && ['d1', 'king'].includes(model.lightDevices[arrayIndices].deviceModel) && !model.lightDevices[arrayIndices].ignoreDevice);"
              }
            },
            "brightnessStep": {
              "title": "Brightness Step",
              "type": "integer",
              "description": "A minimum step for the brightness slider in the Home app. Must be 1 or more.",
              "placeholder": 1,
              "minimum": 1,
              "condition": {
                "functionBody": "return (model.lightDevices && model.lightDevices[arrayIndices] && ['d1', 'l1', 'bulbB02BA60', 'bulbB05BA60', 'bulbB02FA60', 'bulbB02FST64', 'bulbB05BLA19', 'king', 'zl_d', 'zl_dc'].includes(model.lightDevices[arrayIndices].deviceModel) && !model.lightDevices[arrayIndices].ignoreDevice);"
              }
            },
            "adaptiveLightingShift": {
              "title": "Adaptive Lighting Shift",
              "type": "integer",
              "description": "The mired for each Adaptive Lighting update will be increased by this value, making the light appear warmer. Set to -1 to remove Adaptive Lighting feature. Must be -1 or more.",
              "placeholder": 0,
              "minimum": -1,
              "condition": {
                "functionBody": "return (model.lightDevices && model.lightDevices[arrayIndices] && ['l1', 'bulbB02BA60', 'bulbB05BA60', 'bulbB02FA60', 'bulbB02FST64', 'bulbB05BLA19', 'zl_dc'].includes(model.lightDevices[arrayIndices].deviceModel) && !model.lightDevices[arrayIndices].ignoreDevice);"
              }
            },
            "offlineAsOff": {
              "type": "boolean",
              "title": "Offline As Off",
              "description": "If true, this accessory will show as off if reported offline.",
              "condition": {
                "functionBody": "return (model.lightDevices && model.lightDevices[arrayIndices] && model.lightDevices[arrayIndices].deviceId && model.lightDevices[arrayIndices].deviceId.length === 10 && !model.lightDevices[arrayIndices].ignoreDevice);"
              }
            },
            "ipAddress": {
              "type": "string",
              "title": "IP Address",
              "description": "You can manually set the IP address for this device if it cannot be discovered by the plugin.",
              "condition": {
                "functionBody": "return (model.mode !== 'wan' && model.lightDevices && model.lightDevices[arrayIndices] && ['d1', 'bulbB05BLA19'].includes(model.lightDevices[arrayIndices].deviceModel) && !model.lightDevices[arrayIndices].ignoreDevice);"
              }
            }
          }
        }
      },
      "thDevices": {
        "title": "Thermostat Devices",
        "description": "Optional settings for thermostat devices, NSPanel, TH10/16 and THR316/320.",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "label": {
              "title": "Label",
              "type": "string",
              "description": "This setting has no effect except to help identify this device."
            },
            "deviceId": {
              "type": "string",
              "title": "Device ID",
              "description": "Enter the 10 digit eWeLink Device ID to begin.",
              "minLength": 10,
              "maxLength": 10
            },
            "ignoreDevice": {
              "type": "boolean",
              "title": "Hide From HomeKit",
              "description": "If true, this accessory will be removed and ignored from HomeKit.",
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && model.thDevices[arrayIndices].deviceId && model.thDevices[arrayIndices].deviceId.length === 10);"
              }
            },
            "deviceModel": {
              "type": "string",
              "title": "Device Model",
              "description": "This setting has no effect except showing the relevant options for this model below.",
              "oneOf": [
                {
                  "title": "Sonoff TH10/16 and THR316/320",
                  "enum": ["th"]
                },
                {
                  "title": "Sonoff NSPanel",
                  "enum": ["panel"]
                },
                {
                  "title": "Sonoff SC",
                  "enum": ["sc"]
                },
                {
                  "title": "KKMOON HC-T010-EWF",
                  "enum": ["hc"]
                }
              ],
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && model.thDevices[arrayIndices].deviceId && model.thDevices[arrayIndices].deviceId.length === 10 && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            },
            "showAs": {
              "type": "string",
              "title": "Show As (Simulation)",
              "description": "Expose this device as a different HomeKit accessory type.",
              "oneOf": [
                {
                  "title": "1 Switch + Sensors (Default)",
                  "enum": ["default"]
                },
                {
                  "title": "1 Thermostat",
                  "enum": ["thermostat"]
                },
                {
                  "title": "1 Heater",
                  "enum": ["heater"]
                },
                {
                  "title": "1 Cooler",
                  "enum": ["cooler"]
                },
                {
                  "title": "1 Humidifier",
                  "enum": ["humidifier"]
                },
                {
                  "title": "1 Dehumidifier",
                  "enum": ["dehumidifier"]
                }
              ],
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && ['th'].includes(model.thDevices[arrayIndices].deviceModel) && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            },
            "showHeatCool": {
              "type": "boolean",
              "title": "Show Heat/Cool Modes",
              "description": "If true, the 'Heat' and 'Cool' modes will be shown in HomeKit.",
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && ['th'].includes(model.thDevices[arrayIndices].deviceModel) && model.thDevices[arrayIndices].showAs === 'thermostat' && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            },
            "hideSwitch": {
              "type": "boolean",
              "title": "Hide Switch",
              "description": "If true, this accessory will hide the TH10/16 switch from HomeKit.",
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && ['th'].includes(model.thDevices[arrayIndices].deviceModel) && !['thermostat', 'heater', 'cooler', 'humidifier', 'dehumidifier'].includes(model.thDevices[arrayIndices].showAs) && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            },
            "offset": {
              "type": "number",
              "title": "Temperature Offset",
              "description": "You can offset the temperature that the sensor reads. An offset of 2 means 2 degrees will be added to the recorded temperature. Can be positive or negative and can include a decimal point '.'.",
              "placeholder": 0,
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && ['th', 'sc', 'hc', 'panel'].includes(model.thDevices[arrayIndices].deviceModel) && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            },
            "offsetFactor": {
              "type": "boolean",
              "title": "Temperature Offset Factor",
              "description": "If true then the above value will be used as a factor, i.e. the recorded temperature will be multipled by this number instead.",
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && ['th', 'sc', 'hc', 'panel'].includes(model.thDevices[arrayIndices].deviceModel) && model.thDevices[arrayIndices].offset && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            },
            "humidityOffset": {
              "type": "number",
              "title": "Humidity Offset",
              "description": "You can offset the humidity that the sensor reads. An offset of 2 means 2% will be added to the recorded relative humidity. Can be positive or negative.",
              "placeholder": 0,
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && ['th', 'sc', 'hc'].includes(model.thDevices[arrayIndices].deviceModel) && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            },
            "humidityOffsetFactor": {
              "type": "boolean",
              "title": "Humidity Offset %",
              "description": "If true then the above value will be used as a factor, i.e. the recorded humidity will be multipled by this number instead.",
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && ['th', 'sc', 'hc'].includes(model.thDevices[arrayIndices].deviceModel) && model.thDevices[arrayIndices].humidityOffset && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            },
            "targetTempThreshold": {
              "type": "number",
              "title": "Target Temperature Threshold",
              "description": "You can add a threshold so the device only switches on when the current temperature is at least the threshold away from the target temperature. This can be useful for devices that don't require an exact temperature and you want to reduce the on-off cycles. Must be positive and can include a decimal point.",
              "placeholder": 0,
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && ['th', 'sc', 'hc', 'panel'].includes(model.thDevices[arrayIndices].deviceModel) && ['heater'].includes(model.thDevices[arrayIndices].showAs) && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            },
            "minTarget": {
              "type": "integer",
              "title": "Minimum Target Temperature",
              "description": "Minimum target temperature for TH10/16 thermostat/heater/cooler simulation to show in HomeKit apps. Must be 0 or more.",
              "placeholder": 10,
              "minimum": 0,
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && ['th'].includes(model.thDevices[arrayIndices].deviceModel) && ['thermostat', 'heater', 'cooler'].includes(model.thDevices[arrayIndices].showAs) && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            },
            "maxTarget": {
              "type": "integer",
              "title": "Maximum Target Temperature",
              "description": "Maximum target temperature for TH10/16 thermostat/heater/cooler simulation to show in HomeKit apps. Must be 1 or more, and greater than the minimum value set above.",
              "placeholder": 30,
              "minimum": 1,
              "condition": {
                "functionBody": "return (model.thDevices && model.thDevices[arrayIndices] && ['th'].includes(model.thDevices[arrayIndices].deviceModel) && ['thermostat', 'heater', 'cooler'].includes(model.thDevices[arrayIndices].showAs) && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            },
            "ipAddress": {
              "type": "string",
              "title": "IP Address",
              "description": "You can manually set the IP address for this Sonoff TH10/16 if it cannot be discovered by the plugin.",
              "condition": {
                "functionBody": "return (model.mode !== 'wan' && model.thDevices && model.thDevices[arrayIndices] && ['th', 'panel'].includes(model.thDevices[arrayIndices].deviceModel) && !model.thDevices[arrayIndices].ignoreDevice);"
              }
            }
          }
        }
      },
      "fanDevices": {
        "title": "Fan Devices",
        "description": "Optional settings for iFan devices.",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "label": {
              "title": "Label",
              "type": "string",
              "description": "This setting has no effect except to help identify this device."
            },
            "deviceId": {
              "type": "string",
              "title": "Device ID",
              "description": "Enter the 10 digit eWeLink Device ID to begin.",
              "minLength": 10,
              "maxLength": 10
            },
            "ignoreDevice": {
              "type": "boolean",
              "title": "Hide From HomeKit",
              "description": "If true, this accessory will be removed and ignored from HomeKit.",
              "condition": {
                "functionBody": "return (model.fanDevices && model.fanDevices[arrayIndices] && model.fanDevices[arrayIndices].deviceId && model.fanDevices[arrayIndices].deviceId.length === 10);"
              }
            },
            "deviceModel": {
              "type": "string",
              "title": "Device Model",
              "description": "This setting has no effect except showing the relevant options for this model below.",
              "oneOf": [
                {
                  "title": "Sonoff iFan/02/03/04",
                  "enum": ["ifan"]
                }
              ],
              "condition": {
                "functionBody": "return (model.fanDevices && model.fanDevices[arrayIndices] && model.fanDevices[arrayIndices].deviceId && model.fanDevices[arrayIndices].deviceId.length === 10 && !model.fanDevices[arrayIndices].ignoreDevice);"
              }
            },
            "hideLight": {
              "type": "boolean",
              "title": "Hide Light Switch",
              "description": "If true, the light switch will be hidden from HomeKit.",
              "condition": {
                "functionBody": "return (model.fanDevices && model.fanDevices[arrayIndices] && ['ifan'].includes(model.fanDevices[arrayIndices].deviceModel) && !model.fanDevices[arrayIndices].ignoreDevice);"
              }
            },
            "ipAddress": {
              "type": "string",
              "title": "IP Address",
              "description": "You can manually set the IP address for this device if it cannot be discovered by the plugin.",
              "condition": {
                "functionBody": "return (model.mode !== 'wan' && model.fanDevices && model.fanDevices[arrayIndices] && ['ifan'].includes(model.fanDevices[arrayIndices].deviceModel) && !model.fanDevices[arrayIndices].ignoreDevice);"
              }
            }
          }
        }
      },
      "sensorDevices": {
        "title": "Sensor Devices",
        "description": "Optional settings for the DW2 and Zigbee sensor devices.",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "label": {
              "title": "Label",
              "type": "string",
              "description": "This setting has no effect except to help identify this device."
            },
            "deviceId": {
              "type": "string",
              "title": "Device ID",
              "description": "Enter the 10 digit eWeLink Device ID to begin.",
              "minLength": 10,
              "maxLength": 10
            },
            "ignoreDevice": {
              "type": "boolean",
              "title": "Hide From HomeKit",
              "description": "If true, this accessory will be removed and ignored from HomeKit.",
              "condition": {
                "functionBody": "return (model.sensorDevices && model.sensorDevices[arrayIndices] && model.sensorDevices[arrayIndices].deviceId && model.sensorDevices[arrayIndices].deviceId.length === 10);"
              }
            },
            "deviceModel": {
              "type": "string",
              "title": "Device Model",
              "description": "This setting has no effect except showing the relevant options for this model below.",
              "oneOf": [
                {
                  "title": "Sonoff DW2-Wifi",
                  "enum": ["dw"]
                },
                {
                  "title": "Sonoff SNZB-01 Button",
                  "enum": ["snzb01"]
                },
                {
                  "title": "Sonoff SNZB-02 Temp/Humidity",
                  "enum": ["snzb02"]
                },
                {
                  "title": "Sonoff SNZB-03 Motion",
                  "enum": ["snzb03"]
                },
                {
                  "title": "Sonoff SNZB-04 Door/Window",
                  "enum": ["snzb04"]
                },
                {
                  "title": "Zigbee Leak Sensor",
                  "enum": ["leak"]
                }
              ],
              "condition": {
                "functionBody": "return (model.sensorDevices && model.sensorDevices[arrayIndices] && model.sensorDevices[arrayIndices].deviceId && model.sensorDevices[arrayIndices].deviceId.length === 10 && !model.sensorDevices[arrayIndices].ignoreDevice);"
              }
            },
            "showAs": {
              "type": "string",
              "title": "Show As (Simulation)",
              "description": "Expose this device as a different HomeKit accessory type.",
              "oneOf": [
                {
                  "title": "1 Contact Sensor (Default)",
                  "enum": ["default"]
                },
                {
                  "title": "1 Leak Sensor",
                  "enum": ["sensor_leak"]
                }
              ],
              "condition": {
                "functionBody": "return (model.sensorDevices && model.sensorDevices[arrayIndices] && ['dw'].includes(model.sensorDevices[arrayIndices].deviceModel) && !model.sensorDevices[arrayIndices].ignoreDevice);"
              }
            },
            "lowBattThreshold": {
              "type": "integer",
              "title": "Low Battery Threshold",
              "description": "HomeKit will set the low battery status for this device when the battery (if it has one) reaches this percentage level. Must be 5 or more.",
              "placeholder": 25,
              "minimum": 5,
              "condition": {
                "functionBody": "return (model.sensorDevices && model.sensorDevices[arrayIndices] && ['dw', 'snzb01', 'snzb02', 'snzb03', 'snzb04', 'leak'].includes(model.sensorDevices[arrayIndices].deviceModel) && !model.sensorDevices[arrayIndices].ignoreDevice);"
              }
            },
            "offset": {
              "type": "number",
              "title": "Temperature Offset",
              "description": "You can offset the temperature that the SNZB-02 sensor reads. An offset of 2 means 2 degrees will be added to the recorded temperature. Can be positive or negative and can include a decimal point '.'.",
              "placeholder": 0,
              "condition": {
                "functionBody": "return (model.sensorDevices && model.sensorDevices[arrayIndices] && ['snzb02'].includes(model.sensorDevices[arrayIndices].deviceModel) && !model.sensorDevices[arrayIndices].ignoreDevice);"
              }
            },
            "offsetFactor": {
              "type": "boolean",
              "title": "Temperature Offset Factor",
              "description": "If true then the above value will be used as a factor, i.e. the recorded temperature will be multipled by this number instead.",
              "condition": {
                "functionBody": "return (model.sensorDevices && model.sensorDevices[arrayIndices] && ['snzb02'].includes(model.sensorDevices[arrayIndices].deviceModel) && sensorDevices[arrayIndices].offset && !model.sensorDevices[arrayIndices].ignoreDevice);"
              }
            },
            "humidityOffset": {
              "type": "number",
              "title": "Humidity Offset",
              "description": "You can offset the humidity that the SNZB-02 sensor reads. An offset of 2 means 2% will be added to the recorded relative humidity. Can be positive or negative.",
              "placeholder": 0,
              "condition": {
                "functionBody": "return (model.sensorDevices && model.sensorDevices[arrayIndices] && ['snzb02'].includes(model.sensorDevices[arrayIndices].deviceModel) && !model.sensorDevices[arrayIndices].ignoreDevice);"
              }
            },
            "humidityOffsetFactor": {
              "type": "boolean",
              "title": "Humidity Offset %",
              "description": "If true then the above value will be used as a factor, i.e. the recorded humidity will be multipled by this number instead.",
              "condition": {
                "functionBody": "return (model.sensorDevices && model.sensorDevices[arrayIndices] && ['snzb02'].includes(model.sensorDevices[arrayIndices].deviceModel) && sensorDevices[arrayIndices].humidityOffset && !model.sensorDevices[arrayIndices].ignoreDevice);"
              }
            },
            "hideLongDouble": {
              "type": "boolean",
              "title": "Hide Long & Double Press",
              "description": "If true, double and long press options will be hidden for this Zigbee Button.",
              "condition": {
                "functionBody": "return (model.sensorDevices && model.sensorDevices[arrayIndices] && ['snzb01'].includes(model.sensorDevices[arrayIndices].deviceModel) && !model.sensorDevices[arrayIndices].ignoreDevice);"
              }
            },
            "scaleBattery": {
              "type": "boolean",
              "title": "Scale Battery",
              "description": "If true, the battery reading for this Zigbee Contact Sensor will be multiplied by 10.",
              "condition": {
                "functionBody": "return (model.sensorDevices && model.sensorDevices[arrayIndices] && ['snzb04'].includes(model.sensorDevices[arrayIndices].deviceModel) && !model.sensorDevices[arrayIndices].ignoreDevice);"
              }
            },
            "sensorTimeDifference": {
              "type": "integer",
              "title": "Sensor Lag",
              "description": "An offset in seconds to ignore notifications if the delay between this Zigbee Motion/Leak activating or Zigbee Button press and the plugin receiving the notification is greater than this number. Must be 5 or more.",
              "placeholder": 60,
              "minimum": 5,
              "condition": {
                "functionBody": "return (model.sensorDevices && model.sensorDevices[arrayIndices] && ['snzb01', 'snzb03', 'leak'].includes(model.sensorDevices[arrayIndices].deviceModel) && !model.sensorDevices[arrayIndices].ignoreDevice);"
              }
            }
          }
        }
      },
      "rfDevices": {
        "title": "RF Devices",
        "description": "Optional settings for RF Bridge devices.",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "label": {
              "title": "Label",
              "type": "string",
              "description": "This setting has no effect except to help identify this device."
            },
            "deviceId": {
              "type": "string",
              "title": "Device ID",
              "description": "Enter the 10 digit eWeLink Device ID to begin.",
              "minLength": 10,
              "maxLength": 10
            },
            "ignoreDevice": {
              "type": "boolean",
              "title": "Hide From HomeKit",
              "description": "If true, this accessory will be removed and ignored from HomeKit.",
              "condition": {
                "functionBody": "return (model.rfDevices && model.rfDevices[arrayIndices] && model.rfDevices[arrayIndices].deviceId && model.rfDevices[arrayIndices].deviceId.length === 10);"
              }
            },
            "resetOnStartup": {
              "title": "Reset Subdevices",
              "type": "boolean",
              "description": "If true, the plugin will remove and re-add all subdevices when the plugin initialises. Useful if adding or removing subdevices via the eWeLink app.",
              "condition": {
                "functionBody": "return (model.rfDevices && model.rfDevices[arrayIndices] && model.rfDevices[arrayIndices].deviceId && model.rfDevices[arrayIndices].deviceId.length === 10 && !model.rfDevices[arrayIndices].ignoreDevice);"
              }
            },
            "ipAddress": {
              "type": "string",
              "title": "IP Address",
              "description": "You can manually set the IP address for this device if it cannot be discovered by the plugin.",
              "condition": {
                "functionBody": "return (model.mode !== 'wan' && model.rfDevices && model.rfDevices[arrayIndices] && model.rfDevices[arrayIndices].deviceId && model.rfDevices[arrayIndices].deviceId.length === 10 && !model.rfDevices[arrayIndices].ignoreDevice);"
              }
            }
          }
        }
      },
      "bridgeSensors": {
        "title": "RF Sensor Devices",
        "description": "Optional settings for RF Bridge subdevices to expose different sensor types (<a href=\"https://github.com/bwp91/homebridge-ewelink/wiki/RF-Bridge-Sensors\" target=\"_blank\">more info</a>).",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "label": {
              "title": "Label",
              "type": "string",
              "description": "This setting has no effect except to help identify this device."
            },
            "fullDeviceId": {
              "type": "string",
              "title": "Sensor Device ID",
              "description": "Enter the Device ID of the sensor to begin (13 digits normally in the format 1000ab23cdSW2).",
              "minLength": 13,
              "maxLength": 15
            },
            "deviceType": {
              "type": "string",
              "title": "Device Type",
              "description": "Select the type of RF device this is.",
              "oneOf": [
                {
                  "title": "Button(s) (Default)",
                  "enum": ["button"]
                },
                {
                  "title": "Curtain",
                  "enum": ["curtain"]
                },
                {
                  "title": "Sensor/Doorbell",
                  "enum": ["sensor"]
                }
              ],
              "condition": {
                "functionBody": "return (model.bridgeSensors && model.bridgeSensors[arrayIndices] && model.bridgeSensors[arrayIndices].fullDeviceId && model.bridgeSensors[arrayIndices].fullDeviceId.length >= 13);"
              }
            },
            "curtainType": {
              "type": "string",
              "title": "Curtain Type",
              "description": "Select the type of accessory you would like to expose this as.",
              "oneOf": [
                {
                  "title": "3 Buttons (Open, Close, Stop) (Default)",
                  "enum": ["buttons"]
                },
                {
                  "title": "Window Blind/Covering",
                  "enum": ["blind"]
                },
                {
                  "title": "Door",
                  "enum": ["door"]
                },
                {
                  "title": "Window",
                  "enum": ["window"]
                }
              ],
              "condition": {
                "functionBody": "return (model.bridgeSensors && model.bridgeSensors[arrayIndices] && model.bridgeSensors[arrayIndices].fullDeviceId && model.bridgeSensors[arrayIndices].fullDeviceId.length >= 13 && model.bridgeSensors[arrayIndices].deviceType === 'curtain');"
              }
            },
            "operationTime": {
              "type": "integer",
              "title": "Operation Time (Deciseconds)",
              "description": "The time to open/close the device. This setting is in deciseconds - count the time in seconds and multiply by 10, for example 75 for 7.5 seconds. Must be 20 or more.",
              "placeholder": 100,
              "minimum": 20,
              "condition": {
                "functionBody": "return (model.bridgeSensors && model.bridgeSensors[arrayIndices] && model.bridgeSensors[arrayIndices].fullDeviceId && model.bridgeSensors[arrayIndices].fullDeviceId.length >= 13 && model.bridgeSensors[arrayIndices].deviceType === 'curtain' && ['blind', 'door', 'window'].includes(model.bridgeSensors[arrayIndices].curtainType));"
              }
            },
            "operationTimeDown": {
              "type": "integer",
              "title": "Operation Time Down (Deciseconds)",
              "description": "If your device has a different operation time for up and down, use this setting to specify the operation time DOWN (in deciseconds) and the other setting to specify the operation time UP. Otherwise leave blank. Must be 20 or more.",
              "placeholder": 100,
              "minimum": 20,
              "condition": {
                "functionBody": "return (model.bridgeSensors && model.bridgeSensors[arrayIndices] && model.bridgeSensors[arrayIndices].fullDeviceId && model.bridgeSensors[arrayIndices].fullDeviceId.length >= 13 && model.bridgeSensors[arrayIndices].deviceType === 'curtain' && ['blind', 'door', 'window'].includes(model.bridgeSensors[arrayIndices].curtainType));"
              }
            },
            "type": {
              "type": "string",
              "title": "Sensor Type",
              "description": "Select the type of sensor you would like to expose this as.",
              "oneOf": [
                {
                  "title": "Motion (Default)",
                  "enum": ["motion"]
                },
                {
                  "title": "Smoke/Fire",
                  "enum": ["smoke"]
                },
                {
                  "title": "Water/Leak",
                  "enum": ["water"]
                },
                {
                  "title": "Carbon Monoxide",
                  "enum": ["co"]
                },
                {
                  "title": "Carbon Dioxide",
                  "enum": ["co2"]
                },
                {
                  "title": "Occupancy",
                  "enum": ["occupancy"]
                },
                {
                  "title": "Contact",
                  "enum": ["contact"]
                },
                {
                  "title": "Programmable Button",
                  "enum": ["p_button"]
                },
                {
                  "title": "Doorbell",
                  "enum": ["doorbell"]
                }
              ],
              "condition": {
                "functionBody": "return (model.bridgeSensors && model.bridgeSensors[arrayIndices] && model.bridgeSensors[arrayIndices].fullDeviceId && model.bridgeSensors[arrayIndices].fullDeviceId.length >= 13 && model.bridgeSensors[arrayIndices].deviceType === 'sensor');"
              }
            },
            "sensorTimeLength": {
              "type": "integer",
              "title": "Sensor Time Length",
              "description": "The number of seconds which the sensor tile in the Home app will light up for if this sensor is activated. Must be 1 or more.",
              "placeholder": 60,
              "minimum": 1,
              "condition": {
                "functionBody": "return (model.bridgeSensors && model.bridgeSensors[arrayIndices] && model.bridgeSensors[arrayIndices].type && model.bridgeSensors[arrayIndices].deviceType === 'sensor' && ['motion', 'smoke', 'water', 'co', 'co2', 'occupancy', 'contact'].includes(model.bridgeSensors[arrayIndices].type));"
              }
            },
            "sensorTimeDifference": {
              "type": "integer",
              "title": "Sensor Lag",
              "description": "An offset in seconds to ignore notifications if the delay between this sensor activating and the plugin receiving the notification is greater than this number. Must be 5 or more.",
              "placeholder": 60,
              "minimum": 5,
              "condition": {
                "functionBody": "return (model.bridgeSensors && model.bridgeSensors[arrayIndices] && model.bridgeSensors[arrayIndices].type && model.bridgeSensors[arrayIndices].deviceType === 'sensor' && ['motion', 'smoke', 'water', 'co', 'co2', 'occupancy', 'contact'].includes(model.bridgeSensors[arrayIndices].type));"
              }
            },
            "sensorWebHook": {
              "type": "string",
              "title": "Sensor Web Hook",
              "description": "A URL for the plugin to ping when the sensor is activated.",
              "placeholder": "http://192.168.1.1/endpoint",
              "condition": {
                "functionBody": "return (model.bridgeSensors && model.bridgeSensors[arrayIndices] && model.bridgeSensors[arrayIndices].type && model.bridgeSensors[arrayIndices].deviceType === 'sensor' && ['motion', 'smoke', 'water', 'co', 'co2', 'occupancy', 'contact', 'p_button', 'doorbell'].includes(model.bridgeSensors[arrayIndices].type));"
              }
            }
          }
        }
      }
    }
  },
  "layout": [
    {
      "type": "fieldset",
      "title": "Required Settings",
      "items": ["username", "password", "mode"]
    },
    {
      "type": "fieldset",
      "title": "Advanced Settings",
      "description": "Advanced settings for the plugin, including account and API options.",
      "expandable": true,
      "items": [
        "language",
        "disableDeviceLogging",
        "disableNoResponse",
        "ignoredHomes",
        "countryCode",
        "httpHost",
        "appId",
        "appSecret",
        "apiPort"
      ]
    },
    {
      "key": "singleDevices",
      "title": "Single Channel Devices",
      "description": "Optional settings for single-channel switch, outlet and light switch devices.",
      "expandable": true,
      "add": "Add Another Device",
      "type": "array",
      "items": [
        {
          "type": "fieldset",
          "items": [
            "singleDevices[].label",
            "singleDevices[].deviceId",
            "singleDevices[].ignoreDevice",
            "singleDevices[].deviceModel",
            "singleDevices[].showAs",
            "singleDevices[].showAsMotor",
            "singleDevices[].showAsEachen",
            "singleDevices[].inUsePowerThreshold",
            "singleDevices[].disableTimer",
            "singleDevices[].temperatureSource",
            "singleDevices[].isInched",
            "singleDevices[].operationTime",
            "singleDevices[].operationTimeDown",
            "singleDevices[].sensorId",
            "singleDevices[].hideSensor",
            "singleDevices[].obstructId",
            "singleDevices[].sensorType",
            "singleDevices[].ipAddress"
          ]
        }
      ]
    },
    {
      "key": "multiDevices",
      "title": "Multi Channel Devices",
      "description": "Optional settings for multi-channel switch, outlet and light switch devices.",
      "expandable": true,
      "add": "Add Another Device",
      "type": "array",
      "items": [
        {
          "type": "fieldset",
          "items": [
            "multiDevices[].label",
            "multiDevices[].deviceId",
            "multiDevices[].ignoreDevice",
            "multiDevices[].deviceModel",
            "multiDevices[].showAs",
            "multiDevices[].showAsMotor",
            "multiDevices[].hideChannels",
            "multiDevices[].inUsePowerThreshold",
            "multiDevices[].disableTimer",
            "multiDevices[].inchChannels",
            "multiDevices[].sensorType",
            "multiDevices[].operationTime",
            "multiDevices[].operationTimeDown",
            "multiDevices[].sensorId",
            "multiDevices[].hideSensor",
            "multiDevices[].obstructId",
            "multiDevices[].ipAddress"
          ]
        }
      ]
    },
    {
      "key": "lightDevices",
      "title": "Light Devices",
      "description": "Optional settings for dimmer, bulb and LED strip devices.",
      "expandable": true,
      "add": "Add Another Device",
      "type": "array",
      "items": [
        {
          "type": "fieldset",
          "items": [
            "lightDevices[].label",
            "lightDevices[].deviceId",
            "lightDevices[].ignoreDevice",
            "lightDevices[].deviceModel",
            "lightDevices[].showAs",
            "lightDevices[].brightnessStep",
            "lightDevices[].adaptiveLightingShift",
            "lightDevices[].offlineAsOff",
            "lightDevices[].ipAddress"
          ]
        }
      ]
    },
    {
      "key": "thDevices",
      "title": "Thermostat Devices",
      "description": "Optional settings for thermostat devices, NSPanel and the TH10/16.",
      "expandable": true,
      "add": "Add Another Device",
      "type": "array",
      "items": [
        {
          "type": "fieldset",
          "items": [
            "thDevices[].label",
            "thDevices[].deviceId",
            "thDevices[].ignoreDevice",
            "thDevices[].deviceModel",
            "thDevices[].showAs",
            "thDevices[].showHeatCool",
            "thDevices[].hideSwitch",
            "thDevices[].offset",
            "thDevices[].offsetFactor",
            "thDevices[].humidityOffset",
            "thDevices[].humidityOffsetFactor",
            "thDevices[].targetTempThreshold",
            "thDevices[].minTarget",
            "thDevices[].maxTarget",
            "thDevices[].ipAddress"
          ]
        }
      ]
    },
    {
      "key": "fanDevices",
      "title": "Fan Devices",
      "description": "Optional settings for iFan devices.",
      "expandable": true,
      "add": "Add Another Device",
      "type": "array",
      "items": [
        {
          "type": "fieldset",
          "items": [
            "fanDevices[].label",
            "fanDevices[].deviceId",
            "fanDevices[].ignoreDevice",
            "fanDevices[].deviceModel",
            "fanDevices[].hideLight",
            "fanDevices[].ipAddress"
          ]
        }
      ]
    },
    {
      "key": "sensorDevices",
      "title": "Sensor Devices",
      "description": "Optional settings for the DW2 and Zigbee sensor devices.",
      "expandable": true,
      "add": "Add Another Device",
      "type": "array",
      "items": [
        {
          "type": "fieldset",
          "items": [
            "sensorDevices[].label",
            "sensorDevices[].deviceId",
            "sensorDevices[].ignoreDevice",
            "sensorDevices[].deviceModel",
            "sensorDevices[].showAs",
            "sensorDevices[].lowBattThreshold",
            "sensorDevices[].offset",
            "sensorDevices[].offsetFactor",
            "sensorDevices[].humidityOffset",
            "sensorDevices[].humidityOffsetFactor",
            "sensorDevices[].hideLongDouble",
            "sensorDevices[].scaleBattery",
            "sensorDevices[].sensorTimeDifference"
          ]
        }
      ]
    },
    {
      "key": "rfDevices",
      "title": "RF Bridge Devices",
      "description": "Optional settings for RF Bridge devices.",
      "expandable": true,
      "add": "Add Another Device",
      "type": "array",
      "items": [
        {
          "type": "fieldset",
          "items": [
            "rfDevices[].label",
            "rfDevices[].deviceId",
            "rfDevices[].ignoreDevice",
            "rfDevices[].resetOnStartup",
            "rfDevices[].ipAddress"
          ]
        }
      ]
    },
    {
      "key": "bridgeSensors",
      "title": "RF Subdevices",
      "description": "Optional settings for RF Bridge subdevices to expose different sensor types (<a href=\"https://github.com/bwp91/homebridge-ewelink/wiki/RF-Bridge-Sensors\" target=\"_blank\">more info</a>).",
      "expandable": true,
      "add": "Add Another Sensor",
      "type": "array",
      "items": [
        {
          "type": "fieldset",
          "items": [
            "bridgeSensors[].label",
            "bridgeSensors[].fullDeviceId",
            "bridgeSensors[].deviceType",
            "bridgeSensors[].curtainType",
            "bridgeSensors[].operationTime",
            "bridgeSensors[].operationTimeDown",
            "bridgeSensors[].type",
            "bridgeSensors[].sensorTimeLength",
            "bridgeSensors[].sensorTimeDifference",
            "bridgeSensors[].sensorWebHook"
          ]
        }
      ]
    }
  ]
}
