Действия Google Home Sync: полезная нагрузка - PullRequest
0 голосов
/ 06 мая 2018

Ниже приведена полезная нагрузка, созданная для намерения SYNC. При тестировании в средстве проверки умного дома он анализирует json без каких-либо проблем.

Полезная нагрузка ответа Sync:

{
    "payload": {
        "agentUserId": "myhome",
        "devices": [
            {
                "traits": [
                    "action.devices.traits.OnOff"
                ],
                "willReportState": false,
                "name": {
                    "defaultNames": [],
                    "name": "Sky Light",
                    "nicknames": []
                },
                "attributes": [],
                "customData": "",
                "id": "BED_LIGHT",
                "type": "action.devices.types.LIGHT",
                "deviceInfo": {
                    "swVersion": "1.0",
                    "model": "Light",
                    "manufacturer": "Connected Smart Life",
                    "hwVersion": "1.0"
                }
            },
            {
                "traits": [
                    "action.devices.traits.OnOff"
                ],
                "willReportState": false,
                "name": {
                    "defaultNames": [],
                    "name": "Ruthu Room Round Light",
                    "nicknames": []
                },
                "attributes": [],
                "customData": "",
                "id": "SWITCH94",
                "type": "action.devices.types.LIGHT",
                "deviceInfo": {
                    "swVersion": "1.0",
                    "model": "Light",
                    "manufacturer": "Connected Smart Life",
                    "hwVersion": "1.0"
                }
            }
        ]
    },
    "requestId": "18338945788402571764"
}

Но в Google Assistant Actions не удалось разобрать это, и в журнале отображается сообщение об ошибке:

{
  insertId: "1ha0kvhg1kf0a0t"
  logName: "projects/connectedghome/logs/actions.googleapis.com%2Factions"
  receiveTimestamp: "2018-05-05T21:04:27.318451222Z"
  resource: {…}
  severity: "ERROR"
  textPayload: "SYNC: Request ID 18338945788402571764 update devices failed: INVALID_ARGUMENT. Detail: Error: [Expect a map object but found: []] while parsing JSON [{"payload":{"agentUserId":"myhome","devices":[{"attributes":[],"customData":"","deviceInfo":{"hwVersion":"1.0","manufacturer":"Connected Smart Life","model":"Light","swVersion":"1.0"},"id":"BED_LIGHT","name":{"defaultNames":[],"name":"Sky Light","nicknames":[]},"traits":["action.devices.traits.OnOff"],"type":"action.devices.types.LIGHT","willReportState":false},{"attributes":[],"customData":"","deviceInfo":{"hwVersion":"1.0","manufacturer":"Connected Smart Life","model":"Light","swVersion":"1.0"},"id":"SWITCH94","name":{"defaultNames":[],"name":"Ruthu Room Round Light","nicknames":[]},"traits":["action.devices.traits.OnOff"],"type":"action.devices.types.LIGHT","willReportState":false}]},"requestId":"18338945788402571764"}]"
  timestamp: "2018-05-05T21:04:27.284259780Z"
}

Я что-то здесь упускаю?

1 Ответ

0 голосов
/ 06 мая 2018

Атрибуты должны быть объектом JSON или не определены.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...