智能家居旋转 trait 架构
action.devices.traits.Rotation - 此 trait 属于支持旋转的设备。
旋转度数可以以百分比或度数指定,如果设备支持按度数旋转,默认旋转方向为顺时针。
设备属性
具有此 trait 的设备可能会在 SYNC 操作中报告以下属性。如需详细了解如何处理 SYNC intent,请参阅intent 执行方式。
| 属性 | 类型 | 说明 |
|---|---|---|
supportsDegrees |
布尔值 |
必填。 如果设备允许按度数旋转,请将此值设置为 true。 |
supportsPercent |
布尔值 |
必填。 如果设备允许按百分比旋转,请将此值设置为 true |
rotationDegreesRange |
对象 |
表示设备可旋转的角度范围。 |
rotationDegreesMin |
编号 |
必填。 最小旋转角度(以度为单位)。 |
rotationDegreesMax |
编号 |
必填。 最大旋转角度(以度为单位)。 |
supportsContinuousRotation |
布尔值 |
(默认值: 如果设备允许连续旋转,请将此值设为 true。当给定相对查询时, |
commandOnlyRotation |
布尔值 |
(默认值: 指示设备是否支持使用单向(true)或双向(false)通信。如果设备无法响应此 trait 的 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
}设备状态
具有此 trait 的实体可能会在 QUERY 操作期间报告以下状态。如需详细了解如何处理 QUERY intent,请参阅intent 执行方式。
| 州 | 类型 | 说明 |
|---|---|---|
rotationDegrees |
编号 |
|
rotationPercent |
编号 |
当前电量,表示设备当前旋转的百分比。0.0 对应于关闭,100.0 对应于打开。 |
targetRotationPercent |
编号 |
级别,表示设备因旋转持续发生变化而将达到或正在达到的旋转百分比。 |
示例
设备旋转了多少度?(百分比和角度)。
{
"rotationDegrees": 45,
"rotationPercent": 25
}设备旋转了多少度?(仅限度数)。
{
"rotationDegrees": 45
}设备旋转了多少度?(持续)。
{
"rotationDegrees": 270,
"rotationPercent": 75
}设备当前旋转到新位置的百分比。
{
"rotationPercent": 75,
"targetRotationPercent": 100
}设备命令
具有此 trait 的设备可能会在 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