智能家居旋转特征架构

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

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

设备属性

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

属性 类型 说明
supportsDegrees 布尔值

必填。

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

supportsPercent 布尔值

必填。

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

rotationDegreesRange 对象

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

rotationDegreesMin 编号

必填。

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

rotationDegreesMax 编号

必填。

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

supportsContinuousRotation 布尔值

(默认值:false

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

commandOnlyRotation 布尔值

(默认值: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 代表已开业。

targetRotationPercent 编号

水平方向指示设备由于旋转持续变化而将移动到或即将移动到的旋转百分比。

示例

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

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

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

{
  "rotationDegrees": 45
}

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

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

当前旋转到新位置的设备(百分比)。

{
  "rotationPercent": 75,
  "targetRotationPercent": 100
}

设备命令

具有此特征的设备可以在 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

设备 ERRORS

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