{
  "pluginAlias": "PoolControllerPlugin",
  "pluginType": "platform",
  "singular": true,
  "headerDisplay": "Exposes your [poolcontroller](https://github.com/clocklear/poolcontroller) as **one HomeKit accessory** with multiple switches (relays + optional scheduler).\n\n**URL** must point at the API base and include `/api` (example: `https://poolcontroller.example.com/api`). Use the same `API_KEY` configured on the Pi.",
  "footerDisplay": "After saving, restart Homebridge. In the Home app you can show the accessory as multiple tiles if desired. Legacy per-relay accessories from older plugin versions are removed automatically.",
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "title": "Accessory Name",
        "type": "string",
        "default": "Pool Controller",
        "description": "Display name for the HomeKit accessory.",
        "required": true
      },
      "url": {
        "title": "Pool Controller API URL",
        "type": "string",
        "format": "uri",
        "required": true,
        "default": "https://poolcontroller.lockleartech.com/api",
        "description": "Base URL including /api (no trailing slash required)."
      },
      "apiKey": {
        "title": "API Key",
        "type": "string",
        "format": "password",
        "required": true,
        "description": "Value of API_KEY from the poolcontroller server environment."
      },
      "relays": {
        "title": "Relays",
        "description": "Which relays to expose as switches on the accessory.",
        "type": "array",
        "uniqueItems": true,
        "required": true,
        "items": {
          "title": "Relay",
          "type": "string",
          "enum": ["1", "2", "3", "4"],
          "enumNames": ["Relay 1", "Relay 2", "Relay 3", "Relay 4"]
        }
      },
      "exposeScheduler": {
        "title": "Expose Scheduler Switch",
        "type": "boolean",
        "default": true,
        "description": "Add a Scheduler switch that enables/disables the poolcontroller master schedule."
      },
      "exposeLoadSensors": {
        "title": "Expose Load Fault Sensors",
        "type": "boolean",
        "default": false,
        "description": "Add a Contact Sensor per relay that reports load sensing (open = load absent while relay is on). Only created for relays that report load health."
      },
      "pollIntervalSeconds": {
        "title": "Poll Interval (seconds)",
        "type": "integer",
        "default": 30,
        "minimum": 5,
        "maximum": 300,
        "description": "How often to refresh relay/scheduler state from the API and push updates into HomeKit."
      }
    }
  },
  "layout": [
    {
      "type": "fieldset",
      "title": "Connection",
      "items": ["name", "url", "apiKey"]
    },
    {
      "type": "fieldset",
      "title": "Relays",
      "items": ["relays"]
    },
    {
      "type": "fieldset",
      "title": "Features",
      "items": ["exposeScheduler", "exposeLoadSensors"]
    },
    {
      "type": "fieldset",
      "title": "Sync",
      "items": ["pollIntervalSeconds"]
    }
  ]
}
