{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/aqara/json-schema/aqara-trait-value-response-schema.json",
  "title": "TraitValueResponse",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/aiot-api-zh.yaml#/components/schemas/TraitValueResponse",
  "allOf": [
    {
      "$ref": "#/$defs/BaseResponse"
    },
    {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TraitValueResult"
          }
        }
      }
    }
  ],
  "$defs": {
    "BaseResponse": {
      "type": "object",
      "required": [
        "type",
        "version",
        "msgId",
        "code"
      ],
      "properties": {
        "type": {
          "type": "string",
          "description": "消息类型。"
        },
        "version": {
          "type": "string",
          "description": "接口版本。"
        },
        "msgId": {
          "type": "string",
          "description": "消息 ID。"
        },
        "code": {
          "type": "integer",
          "description": "业务状态码，0 表示成功。"
        },
        "message": {
          "type": "string",
          "description": "提示信息。"
        }
      }
    },
    "FlexibleValue": {
      "oneOf": [
        {
          "type": "boolean"
        },
        {
          "type": "integer"
        },
        {
          "type": "number",
          "format": "double"
        },
        {
          "type": "string"
        }
      ],
      "description": "动态值，具体类型取决于 trait/command 定义。\n推荐值类型来源规则：\n1) trait 场景优先读取同级 parameter.type；\n2) command 场景优先读取对应 field 的 parameter.type；\n3) 当 parameter.type=Enum 时，值类型是string；\n4) 若缺少 parameter 或类型未识别，按 string 兜底并保留原始值。\n"
    },
    "TraitValueResult": {
      "type": "object",
      "required": [
        "deviceId",
        "endpointId",
        "functionCode",
        "traitCode",
        "value",
        "time"
      ],
      "properties": {
        "deviceId": {
          "type": "string",
          "description": "设备 ID。"
        },
        "endpointId": {
          "type": "integer",
          "description": "端点 ID。"
        },
        "functionCode": {
          "type": "string",
          "description": "功能编码。"
        },
        "traitCode": {
          "type": "string",
          "description": "功能点代码。"
        },
        "value": {
          "$ref": "#/$defs/FlexibleValue",
          "description": "当前值。类型与 trait 的 parameter.type 的值保持一致。"
        },
        "time": {
          "type": "integer",
          "format": "int64",
          "description": "值更新时间（毫秒级 UTC 时间戳）。"
        }
      }
    }
  }
}