{
  "pluginAlias": "Daikin-Local",
  "pluginType": "accessory",
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "title": "Name",
        "type": "string",
        "required": true,
        "default": "Daikin Livingroom"
      },
      "apiroute": {
        "title": "URI of the WIFI controller.",
        "description": "Should be in the format of: http://aaa.bbb.ccc.ddd or https://aaa.bbb.ccc.ddd",
        "type": "string",
        "required": true,
        "default": "http://192.168.1.33",
        "format": "uri"
      },
      "temperature_unit": {
        "title": "Define Temperature Unit",
        "type": "string",
        "required": true,
        "default": "C",
        "oneOf": [{"title": "Fahrenheit", "enum": ["F"]},
                  {"title": "Celsius", "enum": ["C"]}]
      },
      "temperatureOffsetOutside": {
        "title": "Temperature-Offset-Outside",
        "type": "number",
        "required": false,
        "default": 0.0,
        "minimum": -10.0,
        "maximum": 10.0,
        "step": 0.1,
        "description": "Allows an offset to calibrate the measurement."
      },
      "temperatureOffsetInside": {
        "title": "Temperature-Offset-Inside",
        "type": "number",
        "required": false,
        "default": 0.0,
        "minimum": -10.0,
        "maximum": 10.0,
        "step": 0.1,
        "description": "Allows an offset to calibrate the measurement."
      },
      "uuid": {
        "title": "Client UUID token if needed",
        "description": "Should be a 32 digit hex string. Most Daikin devices do not need a UUID token. Read the documentation: https://github.com/cbrandlehner/homebridge-daikin-local#httpsregistered-client-support",
        "type": "string",
        "required": false
      },
      "system": {
        "type": "string",
        "title": "Controller Type",
        "description": "Select your WiFi controller type: 'Default' for standard Daikin WiFi modules (BRP069xxx), 'Skyfi' for Skyfi controllers, or 'Faikout' for ESP32-Faikout open-source controllers. Choose 'Faikout' if you installed the ESP32-Faikout firmware on an ESP32 chip.",
        "enum": [ "Default", "Skyfi", "Faikout" ],
        "default": "Default",
        "required": true
      },
      "OpenSSL3": {
        "title": "OpenSSL3 support",
        "description": "Use new OpenSSL3 SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION option",
        "type": "boolean",
        "default": false
      },
      "swingMode": {
        "title": "Swing Direction Preference",
        "description": "Choose your preferred swing direction when oscillation is enabled in HomeKit. All controller types support this setting.",
        "type": "string",
        "default": "1",
        "required": true,
        "oneOf": [       
          { "title": "Vertical Swing (default)", "enum": ["1"] },
          { "title": "Horizontal Swing", "enum": ["2"] },
          { "title": "3D Swing (Both Directions)", "enum": ["3"] }
        ]
      },
      "disableFan": {
        "title": "Disable Separate Fan Accessory",
        "description": "When enabled (true), hides the separate Fan accessory from HomeKit main view. Fan speed and oscillation controls in AC settings remain available based on the settings below.",
        "type": "boolean",
        "default": false
      },
      "fanMode": {
        "title": "Fan mode",
        "description": "If in DRY-mode, switching on the FAN in Apple-Home will start the AC in dry mode. If in FAN-mode, it will only activate the FAN.",
        "type": "string", 
        "default": "FAN",
        "required": true,
        "oneOf": [
          { "title": "FAN", "enum": ["FAN"] },
          { "title": "DRY", "enum": ["DRY"] }
        ]
      },
      "fanPowerMode": {
        "title": "Fan power mode",
        "description": "Should Fan power only affect the fan or complete device.",
        "type": "string",
        "default": "FAN only",
        "required": true,
        "enum": [ "FAN only", "Complete Device" ]
      },
      "fanName": {
          "title": "FAN name",
          "description": "The name of the fan. Only applies if the FAN has not been disabled.",
          "type": "string",
          "required": true,
          "default": "Livingroom FAN"
      },
      "defaultMode": {
        "title": "Default operation mode",
        "description": "When turning on the Daikin device in HomeBridge using a single-tap, the default operation mode will be applied. The Daikin-Auto-mode does not match Apple-Homekit - so it is advised to use either COOL- or HEAT-mode if possible.",
        "type": "string",
        "default": "3",
        "oneOf": [
          { "title": "Auto", "enum": ["1"] },
          { "title": "Cool (default)", "enum": ["3"] },
          { "title": "Heat", "enum": ["4"] }
        ],
        "required": true
      },
      "enableHumiditySensor": {
        "title": "Humidity sensor enabled",
        "description": "Enables humidity sensor if present in Daikin device.",
        "type": "boolean",
        "default": false
      },
      "enableTemperatureSensor": {
        "title": "Temperature sensor enabled",
        "description": "Enables temperature sensor in HomeKit.",
        "type": "boolean",
        "default": false
      },
      "enableEconoMode": {
        "title": "Econo Mode switch enabled",
        "description": "Enables a switch in HomeKit to toggle the AC's Econo mode (energy-saving mode). Works with both traditional Daikin and Faikout controllers. Mutually exclusive with Powerful mode.",
        "type": "boolean",
        "default": false
      },
      "econoModeName": {
        "title": "Econo Mode switch name (optional)",
        "description": "Custom name for the Econo Mode switch. Default: 'Econo Mode'. Toggle the switch and check Homebridge logs to identify which one it is.",
        "type": "string",
        "required": false,
        "placeholder": "Econo Mode"
      },
      "enablePowerfulMode": {
        "title": "Powerful Mode switch enabled",
        "description": "Enables a switch in HomeKit to toggle the AC's Powerful mode (maximum cooling/heating). Works with both traditional Daikin and Faikout controllers. Mutually exclusive with Econo mode.",
        "type": "boolean",
        "default": false
      },
      "powerfulModeName": {
        "title": "Powerful Mode switch name (optional)",
        "description": "Custom name for the Powerful Mode switch. Default: 'Powerful Mode'. Toggle the switch and check Homebridge logs to identify which one it is.",
        "type": "string",
        "required": false,
        "placeholder": "Powerful Mode"
      },
      "enableNightQuietMode": {
        "title": "Night Quiet Mode switch enabled",
        "description": "Enables a switch in HomeKit to toggle the AC's Night Quiet mode (silent operation). Faikout uses fan='Q', traditional Daikin uses f_rate='B' (silent). Can be used with Econo or Powerful modes.",
        "type": "boolean",
        "default": false
      },
      "nightQuietModeName": {
        "title": "Night Quiet Mode switch name (optional)",
        "description": "Custom name for the Night Quiet switch. Default: 'Night Quiet'. Toggle the switch and check Homebridge logs to identify which one it is.",
        "type": "string",
        "required": false,
        "placeholder": "Night Quiet"
      },
      "enableFanSpeedInSettings": {
        "title": "Enable Fan Speed in AC Settings",
        "description": "When enabled (default), adds a fan speed slider directly in the AC accessory settings for easy access. Disable this if you only want to use the separate Fan accessory for fan speed control.",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "enableOscillationInSettings": {
        "title": "Enable Oscillation in AC Settings",
        "description": "When enabled (default), adds an oscillation toggle directly in the AC accessory settings. This is independent of fan speed and separate Fan accessory settings.",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "enableVerticalSwingSwitch": {
        "title": "Enable Vertical Swing Switch (Faikout only)",
        "description": "Adds a separate switch in HomeKit to independently control vertical (up/down) swing. Combined with the Horizontal Swing switch, this gives you 3 modes: vertical only, horizontal only, or 3D (both). Only works with Faikout controllers.",
        "type": "boolean",
        "default": false
      },
      "verticalSwingName": {
        "title": "Vertical Swing switch name (optional)",
        "description": "Custom name for the Vertical Swing switch. Default: 'Vertical Swing'.",
        "type": "string",
        "required": false,
        "placeholder": "Vertical Swing"
      },
      "enableHorizontalSwingSwitch": {
        "title": "Enable Horizontal Swing Switch (Faikout only)",
        "description": "Adds a separate switch in HomeKit to independently control horizontal (left/right) swing. Combined with the Vertical Swing switch, this gives you 3 modes: vertical only, horizontal only, or 3D (both). Only works with Faikout controllers.",
        "type": "boolean",
        "default": false
      },
      "horizontalSwingName": {
        "title": "Horizontal Swing switch name (optional)",
        "description": "Custom name for the Horizontal Swing switch. Default: 'Horizontal Swing'.",
        "type": "string",
        "required": false,
        "placeholder": "Horizontal Swing"
      },
      "quietWebSocketLogging": {
        "title": "Quiet WebSocket Logging (Faikout only)",
        "description": "When enabled (default), reduces log noise from WebSocket heartbeat and button status updates. Status messages will use debug level instead of info level. Set to false for verbose debugging.",
        "type": "boolean",
        "default": true,
        "required": false
      },
      "minTemperature": {
        "title": "Minimum Temperature",
        "description": "Minimum temperature setting for your AC unit in Celsius. Most Daikin units support 10°C for heating and 18°C for cooling.",
        "type": "number",
        "default": 18,
        "minimum": 5,
        "maximum": 20,
        "multipleOf": 0.5,
        "required": false
      },
      "maxTemperature": {
        "title": "Maximum Temperature", 
        "description": "Maximum temperature setting for your AC unit in Celsius. Most Daikin units support 30-32°C.",
        "type": "number",
        "default": 30,
        "minimum": 25,
        "maximum": 40,
        "multipleOf": 0.5,
        "required": false
      },
      "response": {
        "title": "Response",
	      "description": "Timeout in milliseconds for the device to start responding.  Default: 2000 (2 seconds).",
        "type": "integer",
        "default": 2000,
        "minimum": 2000,
        "maximum": 8000
      },
      "deadline": {
        "title": "Deadline",
	      "description": "Timeout in milliseconds for the device to complete a response.  Default: 60000 (one minute).",
        "type": "integer",
        "default": 60000,
        "minimum": 10000,
        "maximum": 60000
      },
      "retries": {
        "title": "Retries",
	      "description": "The plugin can retry to reconnect in case of a connection problem. Default: 5.",
        "type": "integer",
        "default": 5,
        "minimum": 0,
        "maximum": 10
      }
    }
  },
  "layout": [
    {
      "type": "help",
      "helpvalue": "<div style='background-color: #e3f2fd; padding: 15px; border-radius: 5px; margin-bottom: 15px;'><h5 style='margin-top: 0;'>🔌 Controller Type Selection</h5><ul style='margin-bottom: 0;'><li><strong>Default:</strong> Standard Daikin WiFi modules (BRP069xxx series)</li><li><strong>Skyfi:</strong> Skyfi WiFi controller models</li><li><strong>Faikout:</strong> ESP32-Faikout open-source controller (uses JSON API instead of query strings) - <a href='https://github.com/revk/ESP32-Faikout' target='_blank' style='color: #1565c0;'>Visit ESP32-Faikout GitHub →</a> for installation guides and compatible hardware lists.</li></ul><p style='margin-bottom: 0; margin-top: 10px;'><em>Faikout controllers automatically use separate horizontal/vertical swing controls and JSON-based API endpoints.</em></p></div>"
    },
    {
      "type": "section",
      "title": "Device Connection",
      "expandable": false,
      "items": [
        "name",
        "apiroute",
        "system",
        "uuid",
        "temperature_unit"
      ]
    },
    {
      "type": "section",
      "title": "Swing & Fan Settings",
      "expandable": true,
      "items": [
        "swingMode",
        {
          "type": "help",
          "helpvalue": "<div style='background-color: #fff3cd; padding: 10px; border-radius: 5px; margin: 10px 0;'><strong>💡 Fan Control Options:</strong><br/><br/>1. <strong>In AC Settings</strong> (recommended): Adds fan speed slider and oscillation toggle directly in your AC accessory settings for quick access<br/><br/>2. <strong>Separate Fan Accessory</strong>: Creates a standalone fan accessory in HomeKit main view<br/><br/>You can enable both, just one, or neither based on your preference. The AC settings options work independently of the separate fan accessory.</div>"
        },
        "enableFanSpeedInSettings",
        "enableOscillationInSettings",
        {
          "type": "help",
          "helpvalue": "<div style='background-color: #e8f5e9; padding: 10px; border-radius: 5px; margin: 10px 0;'><strong>↕↔ Independent Swing Switches (Faikout only):</strong><br/><br/>Enable separate switches for vertical and horizontal swing to get 3 swing modes:<br/>• <strong>Vertical only</strong> - up/down airflow<br/>• <strong>Horizontal only</strong> - left/right airflow<br/>• <strong>3D mode</strong> - both switches ON<br/><br/>These appear as separate toggles in the Home app and work independently of the main oscillation setting above.</div>"
        },
        "enableVerticalSwingSwitch",
        {
          "key": "verticalSwingName",
          "condition": {
            "functionBody": "return model.enableVerticalSwingSwitch === true;"
          }
        },
        "enableHorizontalSwingSwitch",
        {
          "key": "horizontalSwingName",
          "condition": {
            "functionBody": "return model.enableHorizontalSwingSwitch === true;"
          }
        },
        "disableFan",
        "fanMode",
        "fanPowerMode",
        "fanName"
      ]
    },
    {
      "type": "section",
      "title": "Special Modes (Econo, Powerful, Night Quiet)",
      "expandable": true,
      "items": [
        {
          "type": "help",
          "helpvalue": "<p><strong>Note:</strong> Econo and Powerful modes are mutually exclusive - enabling one will disable the other.</p>"
        },
        "enableEconoMode",
        {
          "key": "econoModeName",
          "condition": {
            "functionBody": "return model.enableEconoMode === true;"
          }
        },
        "enablePowerfulMode",
        {
          "key": "powerfulModeName",
          "condition": {
            "functionBody": "return model.enablePowerfulMode === true;"
          }
        },
        "enableNightQuietMode",
        {
          "key": "nightQuietModeName",
          "condition": {
            "functionBody": "return model.enableNightQuietMode === true;"
          }
        }
      ]
    },
    {
      "type": "section",
      "title": "Additional Sensors & Modes",
      "expandable": true,
      "items": [
        "defaultMode",
        "enableHumiditySensor",
        "enableTemperatureSensor",
        {
          "type": "help",
          "helpvalue": "<div style='background-color: #e7f3ff; padding: 10px; border-radius: 5px; margin: 10px 0;'><strong>🌡️ Temperature Range Settings:</strong><br/>Configure the minimum and maximum temperature limits for your specific Daikin AC unit. Different models support different ranges.</div>"
        },
        "minTemperature",
        "maxTemperature"
      ]
    },
    {
      "type": "section",
      "title": "Advanced Settings",
      "expandable": true,
      "items": [
        {
          "type": "help",
          "helpvalue": "<div style='background-color: #d1ecf1; padding: 10px; border-radius: 5px; margin: 10px 0;'><strong>🌐 Faikout WebSocket Settings:</strong><br/>For Faikout controllers (ESP32-Faikout), quiet logging reduces log noise from status updates while maintaining full functionality.</div>"
        },
        "quietWebSocketLogging",
        "OpenSSL3",
        "response",
        "deadline",
        "retries"
      ]
    }
  ]
}
