智能家居旋转特征架构

action.devices.traits.Rotation - 此特征属于支持旋转的设备。

旋转可以按百分比或角度指定,如果设备支持按度旋转,则默认的旋转方向为顺时针。

设备属性

具有此特征的设备可能会在 SYNC 操作过程中报告以下属性。如需详细了解如何处理 SYNC intent,请参阅 intent 执行方式

属性 类型 说明
supportsDegrees Boolean

必填。

如果设备允许按角度旋转,则设置为 true。

supportsPercent Boolean

必填。

如果设备允许按百分比旋转,则设为 true

rotationDegreesRange 对象

表示设备可以旋转的范围(以度为单位)。

rotationDegreesMin 编号

必填。

最小旋转角度(以度为单位)。

rotationDegreesMax 编号

必填。

最大旋转角度(以度为单位)。

supportsContinuousRotation Boolean

(默认值:false

如果设备允许持续旋转,则设为 true。给定相对查询时,RotateAbsolute 命令会环绕支持的旋转范围。

commandOnlyRotation Boolean

(默认值:false

指明设备是否支持使用单向 (true) 或双向 (false) 通信。如果设备无法响应此特征的 QUERY intent 或报告状态,请将此属性设为 true。

示例

支持以百分比和角度进行旋转的设备

{
  "supportsDegrees": true,
  "supportsPercent": true,
  "rotationDegreesRange": {
    "rotationDegreesMin": 0,
    "rotationDegreesMax": 180
  }
}

仅支持以度为单位旋转的设备

{
  "supportsDegrees": true,
  "supportsPercent": false,
  "rotationDegreesRange": {
    "rotationDegreesMin": 0,
    "rotationDegreesMax": 90
  }
}

仅支持连续旋转命令的设备。

{
  "supportsDegrees": true,
  "supportsPercent": true,
  "rotationDegreesRange": {
    "rotationDegreesMin": 0,
    "rotationDegreesMax": 360
  },
  "supportsContinuousRotation": true,
  "commandOnlyRotation": true
}

设备状态

具有此特征的实体可能会在 QUERY 操作过程中报告以下状态。如需详细了解如何处理 QUERY intent,请参阅 intent 执行方式

类型 说明
rotationDegrees 编号

rotationDegreesRange 内的当前水平,表示设备旋转的度数。该值应始终相对于顺时针旋转。

rotationPercent 编号

表示设备当前旋转角度的百分比的当前水平。0.0 表示封闭,100.0 表示开放。

示例

设备旋转了多少度?(百分比和度数)。

{
  "rotationDegrees": 45,
  "rotationPercent": 25
}

设备旋转了多少度?(仅限度数)。

{
  "rotationDegrees": 45
}

设备旋转了多少度?(持续提供)。

{
  "rotationDegrees": 270,
  "rotationPercent": 75
}

设备命令

具有此特征的设备可能会在 EXECUTE 操作过程中响应以下命令。如需详细了解如何处理 EXECUTE intent,请参阅 intent 执行方式

action.devices.commands.RotateAbsolute

设置设备的绝对旋转角度。

参数

载荷包含以下各项之一:

设置绝对旋转角度(以度为单位)。

参数 类型 说明
rotationDegrees 编号

必填。

绝对值(以度为单位),用于指定设备的最终顺时针旋转。值必须在 rotationDegreesRange 属性中。

设置绝对旋转(以百分比表示)。

参数 类型 说明
rotationPercent 编号

必填。

指定设备最终旋转角度的绝对值(以百分比表示)。

示例

将设备倾斜至百分之 50。

{
  "command": "action.devices.commands.RotateAbsolute",
  "params": {
    "rotationPercent": 50
  }
}

将设备逆时针旋转 15 度 (rotationDegrees: 45)。

{
  "command": "action.devices.commands.RotateAbsolute",
  "params": {
    "rotationDegrees": 30
  }
}

将设备顺时针旋转 100 度(supportsContinuousRotation: truerotationDegrees: 270)。

{
  "command": "action.devices.commands.RotateAbsolute",
  "params": {
    "rotationDegrees": 10
  }
}

设置设备旋转方向时出错。

支持的值:

deviceJammingDetected

设备出错

查看错误和异常的完整列表。