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