{
    "pluginAlias": "DelaySwitch",
    "pluginType": "accessory",
    "singular": false,
    "headerDisplay": "Homebridge plugin for creating delay/timer switches and sensors for delayed actions/automations",
    "footerDisplay": "Created by @nitaybz",
    "schema": {
        "type": "object",
        "properties": {
            "name": {
                "title": "Accessory Name",
                "description": "Name for the accessory",
                "type": "string",
                "required": true
            },
            "delay": {
                "title": "Delay Time",
                "description": "Delay to wait until the switch will be turned OFF. Each activation of the switch will reactivate timer (time will restart). 0 - Timer and sensor are disabled.",
                "type": "integer",
                "default": 5000,
                "required": true
            },
            "delayUnit": {
            "title": "Delay Time Unit",
            "description": "Delay Time Unit (milliseconds/seconds/minutes/hours/days).",
            "type": "string",
            "default": "ms",
            "required": true,
            "oneOf": [
                { "title": "milliseconds", "enum": ["ms"] },
                { "title": "seconds", "enum": ["s"] },
                { "title": "minutes", "enum": ["m"] },
                { "title": "hours", "enum": ["h"] },
                { "title": "days", "enum": ["d"] }
            ]
            },
            "sensorType": {
                "title": "Trigger Sensor Type",
                "description": "Adds an optional sensor that will be activated when the timer comes to an end.",
                "type": "string",
                "default": "motion",
                "required": false,
                "oneOf": [
                  { "title": "Motion Sensor", "enum": ["motion"] },
                  { "title": "Contact Sensor", "enum": ["contact"] },
                  { "title": "Occupancy Sensor", "enum": ["occupancy"] },
                  { "title": "Leak Sensor", "enum": ["leak"] }
                ]
            },
            "flipSensorState": {
                "title": "Flip Sensor State",
                "description": "Enable to flip the trigger sensor state (close/open, detected/not detected).",
                "type": "boolean",
                "default": false,
                "required": false
            },
            "startOnReboot": {
                "title": "Turn ON when Homebridge Restarts",
                "description": "Activate switch after Homebridge restart.",
                "type": "boolean",
                "default": false,
                "required": false
            },
            "debug": {
              "title": "Enable Debug Logs",
              "description": "Produce extra logs for debugging purposes",
              "type": "boolean",
              "default": false,
              "required": false
            }
        }
    },
    "layout": [  
    {
      "type": "fieldset",
      "title": "Basic settings",
      "description": "",
      "expandable": true,
      "expanded": true,
      "items": [
        {
          "type": "flex",
          "flex-flow": "row wrap",
          "items": ["name"]
        },
        {
            "type": "flex",
            "flex-flow": "row wrap",
            "items": ["startOnReboot"]
        }
      ]
    },
    {
      "type": "fieldset",
      "title": "Timer",
      "description": "",
      "expandable": true,
      "expanded": false,
      "items": [
        {
          "type": "flex",
          "flex-flow": "row wrap",
          "items": ["delay", "delayUnit"]
        }
      ]
    },
    {
      "type": "fieldset",
      "title": "Trigger Sensor",
      "description": "",
      "expandable": true,
      "expanded": false,
      "items": [
        {
          "type": "flex",
          "flex-flow": "row wrap",
          "items": ["sensorType", "flipSensorState"]
        }
      ]
    },
    {
      "type": "fieldset",
      "title": "Logs",
      "description": "",
      "expandable": true,
      "expanded": false,
      "items": [
        {
          "type": "flex",
          "flex-flow": "row wrap",
          "items": ["debug"]
        }
      ]
    }
  ]
  }
