在 Google SmartHome API 的 reportState 中,温度 K 和光谱 Rgb 似乎不能一起工作

问题描述

我正在尝试让 Google Smart Home API 在 Gladys Assistant(它是一个开源家庭自动化软件)上运行,但我努力让 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 Api内容

onQuery
{
  'mqtt-lamp-temperature': {
    online: true,on: true
  }
}

但这就是 Google 在集成测试中看到的:

AssertionError: Expected state to include: 
{"color":{"temperatureK":{"xrange":[2600,3200]}}},actual state: {"color":{"spectrumRGB":8388863},"on":true,"online":true}: expected false to be true

google integrations tests

当有光谱Rgb属性时,谷歌似乎完全忽略了温度K属性

为了证实我的理论,我尝试创建一个只有光谱 Rgb 的灯和只有温度 K 的灯,然后它完美地工作。问题是,在这种情况下,一些测试被跳过,我想我不会得到谷歌的验证。

我的问题是:

为什么这些属性不能一起工作?光不能通过温度和RGB来控制吗?

你在我的实现中有什么奇怪的地方吗?

非常感谢您的帮助!

解决方法

来自docs

色温是一个线性标度,是 RGB/HSV 全光谱颜色模型的一个子集。

您当前正尝试向您的灯发送两种不同的颜色设置 (orange-ish in kelvin,deep pink in rgb),这是您遇到的问题的一部分。

您已在 QUERY 中将设备设置为支持 RGB 和温度,但在您的 EXECUTE/{{1}} 意图中,您需要发送任一 温度 K 或 rgb 光谱值,而不是两者。

,

您好,您的 Query 和 ReportState 的 JSON 格式不同,请在 ReportState 中也包含设备 ID,请阅读谷歌报告状态文档以获取更多信息。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...