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

Custom Modes for Actions On Google thermostat


I'm trying to make an app for a thermostat which has some custom modes which the user can set as a base for when they're home, asleep, ... The thermostat works without the custom modes, so i can get and set temperatures. However, when I add the modes, it fails, and I can't find why, the json seems ok by me (sent as a SyncResponse.Payload in java).

{
    "payload": {
        "agentUserId": "qba-001-3464",
        "devices": [
            {
                "traits": [
                    "action.devices.traits.TemperatureSetting",
                    "action.devices.traits.Modes"
                ],
                "willReportState": true,
                "name": {
                    "defaultNames": [
                        "qba-001-3464"
                    ],
                    "name": "qba-001-3464",
                    "nicknames": [
                        "ENGIE boxx"
                    ]
                },
                "attributes": {
                    "availableThermostatModes": [
                        "off",
                        "heat",
                        "cool",
                        "on"
                    ],
                    "thermostatTemperatureRange": {
                        "maxThresholdCelsius": 30,
                        "minThresholdCelsius": 6
                    },
                    "availableModes": [
                        {
                            "ordered": false,
                            "settings": [
                                {
                                    "settingValues": [
                                        {
                                            "lang": "en",
                                            "settingSynonym": [
                                                "comfort"
                                            ]
                                        },
                                        {
                                            "lang": "nl",
                                            "settingSynonym": [
                                                "comfort"
                                            ]
                                        },
                                        {
                                            "lang": "fr",
                                            "settingSynonym": [
                                                "confort"
                                            ]
                                        }
                                    ],
                                    "settingName": "comfort"
                                },
                                {
                                    "settingValues": [
                                        {
                                            "lang": "en",
                                            "settingSynonym": [
                                                "home"
                                            ]
                                        },
                                        {
                                            "lang": "nl",
                                            "settingSynonym": [
                                                "thuis"
                                            ]
                                        },
                                        {
                                            "lang": "fr",
                                            "settingSynonym": [
                                                "maison"
                                            ]
                                        }
                                    ],
                                    "settingName": "home"
                                },
                                {
                                    "settingValues": [
                                        {
                                            "lang": "en",
                                            "settingSynonym": [
                                                "sleep"
                                            ]
                                        },
                                        {
                                            "lang": "nl",
                                            "settingSynonym": [
                                                "slapen"
                                            ]
                                        },
                                        {
                                            "lang": "fr",
                                            "settingSynonym": [
                                                "nuit"
                                            ]
                                        }
                                    ],
                                    "settingName": "sleep"
                                },
                                {
                                    "settingValues": [
                                        {
                                            "lang": "en",
                                            "settingSynonym": [
                                                "away"
                                            ]
                                        },
                                        {
                                            "lang": "nl",
                                            "settingSynonym": [
                                                "weg"
                                            ]
                                        },
                                        {
                                            "lang": "fr",
                                            "settingSynonym": [
                                                "parti"
                                            ]
                                        }
                                    ],
                                    "settingName": "away"
                                },
                                {
                                    "settingValues": [
                                        {
                                            "lang": "en",
                                            "settingSynonym": [
                                                "holiday"
                                            ]
                                        },
                                        {
                                            "lang": "nl",
                                            "settingSynonym": [
                                                "vakantie"
                                            ]
                                        },
                                        {
                                            "lang": "fr",
                                            "settingSynonym": [
                                                "congé"
                                            ]
                                        }
                                    ],
                                    "settingName": "holiday"
                                }
                            ],
                            "nameValues": [
                                {
                                    "nameSynonym": [
                                        "setting",
                                        "mode",
                                        "state"
                                    ],
                                    "lang": "en"
                                },
                                {
                                    "nameSynonym": [
                                        "stand",
                                        "mode",
                                        "state",
                                        "staat",
                                        "instelling"
                                    ],
                                    "lang": "nl"
                                },
                                {
                                    "nameSynonym": [
                                        "réglage",
                                        "mode",
                                        "state"
                                    ],
                                    "lang": "fr"
                                }
                            ],
                            "name": "temperature_state"
                        }
                    ],
                    "thermostatTemperatureUnit": "C"
                },
                "id": "qba-001-3464",
                "type": "action.devices.types.THERMOSTAT",
                "deviceInfo": {
                    "swVersion": "qb2/uni/5.39.6",
                    "model": "ENGIEboxx",
                    "manufacturer": "Toon",
                    "hwVersion": "6599-1500-5000"
                }
            }
        ]
    },
    "requestId": "12754277927386056776"
}

Solution

  • I made 2 mistakes in this json code:

    • The settingValues, settingSynonym, nameValues and nameSynonym all weren't supposed to be camel case --> setting_values, setting_synonym, name_values, name_synonym
    • Apparently Google doesn't allow for accents to be used, so the word "congé" for example had to be "conge" or it would not work.