4

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!

Nick Felker
  • 11,536
  • 1
  • 21
  • 35
Pierre-Gilles
  • 85
  • 1
  • 5

2 Answers2

1

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.

ToniCorinne
  • 503
  • 3
  • 12
  • 1
    Thanks for your answer! Indeed, it's not possible to send both temperatureK and spectrumRgb values! It was not very clear for me, as in the automated tests, it looks like a lamp should absolutely implement everything and return everything. – Pierre-Gilles Jul 29 '21 at 02:55
0

Hi Your JSON format of Query and ReportState is different, include the device id in the ReportState as well, read the google report state docs for more info.

  • I didn't post the full JSON to keep the post short, but I was sending the complete JSON. The issue was that I was sending both temperatureK and spectrumRgb, and those options are not compatible together – Pierre-Gilles Jul 29 '21 at 02:57