我试图让谷歌智能家庭API在Gladys助手上工作(这是一个开源的家庭自动化软件),我很难让Google集成测试通过。
这是我的onSync:
onSync
{
"requestId": "9164924531720238290",
"payload": {
"agentUserId": "9aba8230-9e8d-47b7-9d1c-f4dd8725aad3",
"devices": [
{
"id": "mqtt-lamp-temperature",
"type": "action.devices.types.LIGHT",
"traits": [
"action.devices.traits.ColorSetting",
"action.devices.traits.Brightness",
"action.devices.traits.OnOff"
],
"name": {
"name": "Lampe Temperature"
},
"attributes": {
"colorModel": "rgb",
"colorTemperatureRange": {
"temperatureMinK": 2000,
"temperatureMaxK": 9000
}
},
"deviceInfo": {
"model": null
},
"roomHint": "Grand Salon",
"willReportState": true
}
]
}
}这是我发送给reportState的内容:
reportState
{
online: true,
color: { temperatureK: 3000, spectrumRgb: 8388863 },
on: true
}这就是onQuery返回到Google的内容:
onQuery
{
'mqtt-lamp-temperature': {
online: true,
color: { temperatureK: 3000, spectrumRgb: 8388863 },
on: true
}
}但这正是谷歌在集成测试中所看到的:
AssertionError: Expected state to include:
{"color":{"temperatureK":{"xRange":[2600,3200]}}},
actual state: {"color":{"spectrumRGB":8388863},"on":true,"online":true}: expected false to be true

当temperatureK属性出现时,谷歌似乎完全忽略了spectrumRgb属性。
为了证实我的理论,我试图创造一个只有spectrumRgb和光只有temperatureK的灯,然后它完美地工作。问题是,在这种情况下,一些测试被跳过,我想我不会得到谷歌的验证。
我的问题是:
为什么这些属性不一起工作?光不能由温度和RGB来控制吗?
你觉得我的实现有什么奇怪的地方吗?
非常感谢你的帮助!
发布于 2021-07-20 20:16:32
来自文档
色温是一个线性尺度,是RGB/HSV全光谱颜色模型的一个子集。
您目前正在尝试发送两个不同的颜色设置到您的灯(橙色在开尔文,深粉红色( rgb )),这是您正在遇到的问题的一部分。
您已经在SYNC中设置了设备以支持RGB和温度,但在QUERY/EXECUTE意图中,您需要发送temperatureK或rgb光谱值,而不是同时发送两者。
发布于 2021-07-25 15:23:38
嗨,您的JSON格式的查询和ReportState是不同的,还包括设备id在ReportState中,阅读google状态文档以获得更多信息。
https://stackoverflow.com/questions/68205798
复制相似问题