【问题标题】:In reportState of the Google SmartHome API, temperatureK & spectrumRgb doesn't seem to work together在 Google SmartHome API 的 reportState 中,temperatureK 和spectrumRgb 似乎不能一起工作
【发布时间】:2021-07-01 07:11:50
【问题描述】:

我正在尝试让 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,
    color: { temperatureK: 3000, spectrumRgb: 8388863 },
    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

当 SpectrumRgb 属性在这里时,Google 似乎完全忽略了 temperatureK 属性。

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

我的问题是:

为什么这些属性不能一起工作?灯不能由它的温度和它的 RGB 来控制吗?

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

非常感谢您的帮助!

【问题讨论】:

    标签: actions-on-google google-smart-home


    【解决方案1】:

    来自docs

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

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

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

    【讨论】:

    • 感谢您的回答!实际上,不可能同时发送 temperatureK 和spectrumRgb 值!对我来说不是很清楚,因为在自动化测试中,看起来灯应该绝对实现所有内容并返回所有内容。
    【解决方案2】:

    您好,您的 Query 和 ReportState 的 JSON 格式不同,请在 ReportState 中包含设备 ID,阅读 google 报告状态文档了解更多信息。

    【讨论】:

    • 我没有发布完整的 JSON 以保持帖子简短,但我发送的是完整的 JSON。问题是我同时发送了 temperatureK 和spectrumRgb,而这些选项不兼容
    猜你喜欢
    • 1970-01-01
    • 2017-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-06
    • 2012-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多