{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://phicomm-io.github.io/iotcloud-community-protocols/contracts/schemas/m1-co2-source-set-v1.schema.json",
  "title": "M1 co2_source.set params",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "source",
    "device_id",
    "double_click",
    "revision"
  ],
  "properties": {
    "source": {
      "enum": [
        "local",
        "mqtt"
      ]
    },
    "device_id": {
      "type": "string"
    },
    "double_click": {
      "enum": [
        "none",
        "switch_display"
      ]
    },
    "revision": {
      "type": "integer",
      "minimum": 0,
      "maximum": 2147483647
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "source": {
            "const": "local"
          }
        }
      },
      "then": {
        "properties": {
          "device_id": {
            "const": ""
          }
        }
      },
      "else": {
        "properties": {
          "device_id": {
            "pattern": "^[0-9a-f]{12}$"
          }
        }
      }
    }
  ]
}
