智能家居旋转特征架构
action.devices.traits.Rotation
- 此特征属于支持旋转的设备。
旋转可以按百分比或角度指定,如果设备支持按角度旋转,默认旋转方向为顺时针。
设备属性
具有此特征的设备可以在 SYNC
操作中报告以下属性。如需详细了解如何处理 SYNC
intent,请参阅 intent 执行方式。
属性 | 类型 | 说明 |
---|---|---|
supportsDegrees |
Boolean |
必填。 如果设备允许按角度旋转,则设置为 true。 |
supportsPercent |
Boolean |
必填。 如果设备允许按百分比旋转,则设置为 true |
rotationDegreesRange |
对象 |
表示设备可以旋转的角度范围。 |
rotationDegreesMin |
编号 |
必填。 最小旋转度(以度为单位)。 |
rotationDegreesMax |
编号 |
必填。 最大旋转度(以度为单位)。 |
supportsContinuousRotation |
Boolean |
(默认: 如果设备允许连续旋转,则设为 true。在给定相对查询的情况下, |
commandOnlyRotation |
Boolean |
(默认: 指示设备是否支持单向 (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 |
编号 |
|
rotationPercent |
编号 |
当前级别,指示设备当前旋转百分比。0.0 对应于关闭状态,100.0 对应于打开状态。 |
示例
设备旋转了多长时间?(百分比和角度)。
{ "rotationDegrees": 45, "rotationPercent": 25 }
设备旋转了多长时间?(只有度)。
{ "rotationDegrees": 45 }
设备旋转了多长时间?(持续)。
{ "rotationDegrees": 270, "rotationPercent": 75 }
设备命令
具有此特征的设备可能会在 EXECUTE
操作中响应以下命令。如需详细了解如何处理 EXECUTE
intent,请参阅 intent 执行方式。
action.devices.commands.RotateAbsolute
设置设备的绝对旋转角度。
参数
载荷包含下列各项之一:
设置绝对旋转度(以度为单位)。
参数 | 类型 | 说明 |
---|---|---|
rotationDegrees |
编号 |
必填。 绝对值(以度为单位),用于指定设备的最终顺时针旋转。值必须位于 |
设置绝对旋转(以百分比表示)。
参数 | 类型 | 说明 |
---|---|---|
rotationPercent |
编号 |
必填。 绝对值(以百分比表示),用于指定设备的最终旋转方向。 |
示例
将设备倾斜到 50%。
{ "command": "action.devices.commands.RotateAbsolute", "params": { "rotationPercent": 50 } }
将设备逆时针旋转 15 度 (rotationDegrees: 45
)。
{ "command": "action.devices.commands.RotateAbsolute", "params": { "rotationDegrees": 30 } }
将设备顺时针旋转 100 度(supportsContinuousRotation: true
,rotationDegrees: 270
)。
{ "command": "action.devices.commands.RotateAbsolute", "params": { "rotationDegrees": 10 } }
相关错误
设置设备的旋转方式时出错。
支持的值:
deviceJammingDetected