{
  "pluginAlias": "PurpleAirSensor",
  "pluginType": "platform",
  "singular": true,
  "headerDisplay": "",
  "schema": {
    "type": "object",
    "properties": {
      "apiReadKey": {
        "title": "PurpleAir API read key",
        "type": "string",
        "required": false,
        "description": "Ńot needed when you want to access your private sensors over the local network. To obtain the API read key, reach out to contact@purpleair.com."
      },
      "sensors": {
        "type": "array",
        "items": {
          "type": "object",
          "title": "Sensor",
          "properties": {
            "name": {
              "title": "Name",
              "type": "string",
              "required": true,
              "description": "This name will be used as the accessory name in HomeKit.",
              "placeholder": "PurpleAir Mt. Hamilton"
            },
            "useLocalNetwork": {
              "title": "Use sensor directly on the local network.",
              "type": "boolean",
              "default": false,
              "description": "If checked, you must provide the local IP address of the sensor. Otherwise, PurpleAir public API will be used for which you must provide the API read key."
            },
            "sensor": {
              "title": "Sensor ID",
              "type": "number",
              "required": false,
              "description": "Required. Find the sensor ID by going to <a href='https://www.purpleair.com/map'>PurpleAir's map</a> -> click on a sensor, and look at the URL. It's the number right after 'select='.",
              "condition": {
                "functionBody": "return model.sensors[arrayIndices].useLocalNetwork === false;"
              }
            },
            "localIPAddress": {
              "title": "Sensor IP/hostname",
              "type": "string",
              "required": false,
              "description": "Local IP/hostname address of the sensor",
              "placeholder": "192.168.x.x",
              "format": "hostname",
              "condition": {
                "functionBody": "return model.sensors[arrayIndices].useLocalNetwork === true;"
              }
            },
            "key": {
              "title": "Key for private sensors",
              "type": "string",
              "required": false,
              "description": "Only needed for private sensors. Check the sensor map's URL for the 'key=' string. If you don't have a key, you can leave this field empty and the plugin will try to access the sensor as public. Note: this is different from the API read key.",
              "condition": {
                "functionBody": "return model.sensors[arrayIndices].useLocalNetwork === false;"
              }
            },
            "humidity": {
              "title": "Report humidity",
              "type": "boolean",
              "default": true,
              "description": "If checked, the plugin will report humidity as a separate sensor in HomeKit."
            },
            "temperature": {
              "title": "Report temperature",
              "type": "boolean",
              "default": true,
              "description": "If checked, the plugin will report temperature as a separate sensor in HomeKit."
            }
          }
        }
      },
      "conversion" : {
        "title": "Conversion",
        "type": "string",
        "required": true,
        "default": "None",
        "description": "Conversions help accomodate different types of pollution with different particle densities. Note: for EPA you need to enable fetching humidity.",
        "oneOf": [
          { "title": "None", "enum": ["None"] },
          { "title": "EPA", "enum": ["EPA"] },
          { "title": "AQandU", "enum": ["AQandU"] },
          { "title": "LRAPA", "enum": ["LRAPA"] },
          { "title": "WOODSMOKE", "enum": ["WOODSMOKE"] },
          { "title": "ALT-CF3", "enum": ["ALT-CF3"] }
        ]
      },
      "averages": {
        "title": "Reading Averages",
        "type": "string",
        "description": "Note that for sensors accessed via local network, this config is ignored and always uses 2m average.",
        "required": true,
        "default": "realtime",
        "oneOf": [
          { "title": "Show Realtime", "enum": ["realtime"] },
          { "title": "10 Minute Average", "enum": ["10m"] },
          { "title": "30 Minute Average", "enum": ["30m"] },
          { "title": "One Hour Average", "enum": ["60m"] }
        ]
      },
      "aqiInsteadOfDensity": {
        "title": "Report AQI number instead of density (ug/m^3). HomeKit only allows reporting PM2.5 density instead of AQI value, but some prefer to see AQI value instead. If checked, the plugin will use the density field to report the AQI value.",
        "type": "boolean"
      },
      "updateIntervalSecs": {
        "title": "Sensor refresh interval in seconds",
        "type": "integer",
        "required": false,
        "default": 300,
        "minimum": 30,
        "description": "How often to fetch new sensor readings. Increase this value to reduce PurpleAir API usage."
      },
      "verboseLogging": {
        "title": "Verbose logging. If checked, log more information at info level, so you can see what's happening in homebridge log without running homebridge in debug mode.",
        "type": "boolean"
      }
    }
  }
}
