Schemas

Temperature sensor

An individual temperature sensor reporting degrees Celsius.

https://hometruth.ai/schemas/temperature-sensor · TemperatureSensorDocument

Instances

No devices currently use this schema.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hometruth.ai/schemas/temperature-sensor",
  "title": "Temperature sensor",
  "description": "One temperature sensor owned by a device. Values are degrees Celsius.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "schemaId": {
      "const": "https://hometruth.ai/schemas/temperature-sensor"
    },
    "kind": {
      "const": "temperature"
    },
    "unit": {
      "const": "°C"
    },
    "state": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "availability": {
          "enum": [
            "online",
            "offline",
            "degraded",
            "unknown"
          ]
        },
        "detail": {
          "type": "string",
          "maxLength": 500
        },
        "observedAt": {
          "type": "string",
          "format": "date-time"
        },
        "value": {
          "type": "number",
          "minimum": -273.15
        },
        "source": {
          "type": "string",
          "maxLength": 100
        }
      },
      "required": [
        "availability"
      ],
      "dependentRequired": {
        "value": [
          "observedAt"
        ]
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "availability": {
                "const": "online"
              }
            },
            "required": [
              "availability"
            ]
          },
          "then": {
            "properties": {
              "value": {},
              "observedAt": {}
            },
            "required": [
              "value",
              "observedAt"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "availability": {
                "enum": [
                  "offline",
                  "unknown"
                ]
              }
            },
            "required": [
              "availability"
            ]
          },
          "then": {
            "not": {
              "properties": {
                "value": {}
              },
              "required": [
                "value"
              ]
            }
          }
        }
      ]
    }
  },
  "required": [
    "id",
    "name",
    "schemaId",
    "kind",
    "unit",
    "state"
  ]
}