Search code examples
actions-on-googlegoogle-smart-home

In reportState of the Google SmartHome API, temperatureK & spectrumRgb doesn't seem to work together


I'm trying to make the Google Smart Home API work on Gladys Assistant (it's an open-source home automation software), and I struggle to make Google Integrations tests pass.

This is my 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
            }
        ]
    }
}

This is what I'm sending to reportState:

reportState
{
  online: true,
  color: { temperatureK: 3000, spectrumRgb: 8388863 },
  on: true
}

This is what the onQuery is returning to the Google API:

onQuery
{
  'mqtt-lamp-temperature': {
    online: true,
    color: { temperatureK: 3000, spectrumRgb: 8388863 },
    on: true
  }
}

But this is what Google sees in the integrations tests:

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

It seems Google completely ignores the temperatureK attribute when the spectrumRgb attribute is here.

To confirm my theory, I tried to create a lamp that has only spectrumRgb and a light that has only temperatureK, and then it works perfectly. The problem is, in that case, some tests are skipped and I think I won't get validated by Google with that.

My question is:

Why does those attributes do not work together? Can't a light be controlled by its temperature and by it's RGB ?

Do you see anything weird in my implementation?

Thanks a lot for your help!


Solution

  • From the docs:

    Color temperature is a linear scale and a subset of the RGB/HSV full spectrum color models.

    You're currently trying to send two different color settings to your light (orange-ish in kelvin, deep pink in rgb), which is part of the issue you're running into.

    You have set your device up in your SYNC to support both RGB and temperature, but in your QUERY/EXECUTE intents, you need to send either temperatureK or rgb spectrum values, not both.