{
  "pluginAlias": "homebridge-haier-evo",
  "pluginType": "platform",
  "singular": true,
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "title": "Name",
        "type": "string",
        "required": true,
        "default": "Haier Evo"
      },
      "email": {
        "title": "Email",
        "type": "string",
        "required": true,
        "description": "Your Haier Evo account email"
      },
      "password": {
        "title": "Password",
        "type": "string",
        "required": true,
        "description": "Your Haier Evo account password"
      },
      "region": {
        "title": "Region",
        "type": "string",
        "required": true,
        "default": "ru",
        "oneOf": [
          { "title": "Russia", "enum": ["ru"] },
          { "title": "Kazakhstan", "enum": ["kz"] },
          { "title": "Belarus", "enum": ["by"] }
        ],
        "description": "Your region for the Haier Evo app"
      },
      "refreshInterval": {
        "title": "Refresh Interval",
        "type": "integer",
        "minimum": 300,
        "maximum": 2592000,
        "default": 3600,
        "description": "Device refresh interval in seconds (default: 300)"
      },
      "debug": {
        "title": "Debug Mode",
        "type": "boolean",
        "default": false,
        "description": "Enable debug logging"
      },
      "deviceCacheTTL": {
        "title": "Device Cache TTL",
        "type": "integer",
        "minimum": 300,
        "maximum": 86400,
        "default": 3600,
        "description": "Time in seconds to cache device list (default: 300)"
      },
      "requestRandomization": {
        "title": "Request Randomization",
        "type": "boolean",
        "default": true,
        "description": "Add randomization to requests to appear more natural"
      },
      "minRequestDelay": {
        "title": "Minimum Request Delay",
        "type": "integer",
        "minimum": 50,
        "maximum": 15000,
        "default": 100,
        "description": "Minimum delay between requests in milliseconds (default: 100)"
      },
      "maxRequestDelay": {
        "title": "Maximum Request Delay",
        "type": "integer",
        "minimum": 100,
        "maximum": 30000,
        "default": 1000,
        "description": "Maximum delay between requests in milliseconds (default: 1000)"
      },
      "tokenRefreshMode": {
        "title": "Token Refresh Mode",
        "type": "string",
        "default": "auto",
        "oneOf": [
          { "title": "Auto (Based on Expiration)", "enum": ["auto"] },
          { "title": "Manual (Fixed Interval)", "enum": ["manual"] },
          { "title": "Disabled", "enum": ["disabled"] }
        ],
        "description": "How token refreshes should be handled"
      },
      "tokenRefreshInterval": {
        "title": "Token Refresh Interval",
        "type": "integer",
        "minimum": 60,
        "maximum": 86400,
        "default": 3600,
        "description": "Interval in seconds for manual token refresh (default: 3600 - 1 hour)"
      },
      "tokenRefreshThreshold": {
        "title": "Token Refresh Threshold",
        "type": "integer",
        "minimum": 60,
        "maximum": 3600,
        "default": 300,
        "description": "Time in seconds before token expiration to trigger refresh (default: 300 - 5 minutes)"
      },
      "batchTimeout": {
        "title": "Command Batch Timeout",
        "type": "integer",
        "minimum": 10,
        "maximum": 1000,
        "default": 100,
        "description": "Time in milliseconds to wait before sending batched commands (default: 100ms)"
      },
      "includeDevices": {
        "title": "Include Devices",
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "List of device IDs to include. If specified, only these devices will be added."
      },
      "excludeDevices": {
        "title": "Exclude Devices",
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "List of device IDs to exclude"
      },
      "includeDeviceTypes": {
        "title": "Include Device Types",
        "type": "array",
        "items": {
          "type": "string",
          "enum": ["air_conditioner", "refrigerator"]
        },
        "description": "List of device types to include (e.g., \"air_conditioner\", \"refrigerator\")"
      },
      "excludeDeviceTypes": {
        "title": "Exclude Device Types",
        "type": "array",
        "items": {
          "type": "string",
          "enum": ["air_conditioner", "refrigerator"]
        },
        "description": "List of device types to exclude"
      },
      "includeNamePattern": {
        "title": "Include Name Pattern",
        "type": "string",
        "description": "Regex pattern for device names to include (e.g., \"Living Room|Kitchen\")"
      },
      "excludeNamePattern": {
        "title": "Exclude Name Pattern",
        "type": "string",
        "description": "Regex pattern for device names to exclude"
      },
      "enableFanService": {
        "title": "Enable Fan Service",
        "type": "boolean",
        "default": true,
        "description": "Enable separate Fan v2 service for AC devices"
      },
      "enableBlindsControl": {
        "title": "Enable Blinds Control",
        "type": "boolean",
        "default": true,
        "description": "Enable vertical blinds control using Fan v2 service"
      },
      "enableBlindsAutoSwitch": {
        "title": "Enable Blinds Auto Switch",
        "type": "boolean",
        "default": true,
        "description": "Enable blinds auto mode switch"
      },
      "enableBlindsComfortSwitch": {
        "title": "Enable Blinds Comfort Switch",
        "type": "boolean",
        "default": true,
        "description": "Enable blinds comfort mode switch"
      },
      "enableLightControl": {
        "title": "Enable Light Control",
        "type": "boolean",
        "default": true,
        "description": "Enable light control service for AC devices"
      },
      "enableHealthModeSwitch": {
        "title": "Enable Health Mode Switch",
        "type": "boolean",
        "default": true,
        "description": "Enable health mode switch for AC devices"
      },
      "enableQuietModeSwitch": {
        "title": "Enable Quiet Mode Switch",
        "type": "boolean",
        "default": true,
        "description": "Enable quiet mode switch for AC devices"
      },
      "enableTurboModeSwitch": {
        "title": "Enable Turbo Mode Switch",
        "type": "boolean",
        "default": true,
        "description": "Enable turbo mode switch for AC devices"
      },
      "enableComfortModeSwitch": {
        "title": "Enable Comfort Mode Switch",
        "type": "boolean",
        "default": true,
        "description": "Enable comfort mode switch for AC devices"
      }
    }
  },
  "layout": [
    {
      "type": "fieldset",
      "title": "Account Settings",
      "items": [
        "name",
        "email",
        "password",
        "region",
        "refreshInterval",
        "debug"
      ]
    },
    {
      "type": "fieldset",
      "title": "API Optimization",
      "expandable": true,
      "expanded": false,
      "items": [
        "deviceCacheTTL",
        "requestRandomization",
        "minRequestDelay",
        "maxRequestDelay",
        {
          "type": "fieldset",
          "title": "Token Refresh Settings",
          "items": [
            "tokenRefreshMode",
            "tokenRefreshInterval",
            "tokenRefreshThreshold"
          ]
        },
        {
          "type": "fieldset",
          "title": "Command Batching",
          "items": [
            "batchTimeout"
          ]
        }
      ]
    },
    {
      "type": "fieldset",
      "title": "Device Filtering",
      "expandable": true,
      "expanded": false,
      "items": [
        "includeDevices",
        "excludeDevices",
        "includeDeviceTypes",
        "excludeDeviceTypes",
        "includeNamePattern",
        "excludeNamePattern"
      ]
    },
    {
      "type": "fieldset",
      "title": "AC Accessory Options",
      "expandable": true,
      "expanded": false,
      "items": [
        "enableFanService",
        "enableBlindsControl",
        {
          "type": "fieldset",
          "title": "Blinds Control Switches",
          "items": [
            "enableBlindsAutoSwitch",
            "enableBlindsComfortSwitch"
          ]
        },
        "enableLightControl",
        {
          "type": "fieldset",
          "title": "AC Mode Switches",
          "items": [
            "enableHealthModeSwitch",
            "enableQuietModeSwitch",
            "enableTurboModeSwitch",
            "enableComfortModeSwitch"
          ]
        }
      ]
    }
  ]
}
