0

I am able to pass the Test Suite but suddenly I'm getting the error 404 on the first time Report State after SYNC, which causes Account Linking failed. I have used the Validator provided at Smart Home Developer portal for my SYNC response which has no issue. And I found if I STOP then START my instance at GCP console, this issue is gone but comes back after a couple times of Account Linking and Unlink.

SYNC JSON object:

{
  "requestId": "8044981777755038463",
  "payload": {
  "agentUserId": "123456789",
  "devices": [
    {
      "id": "123-Fan",
      "type": "action.devices.types.FAN",
      "traits": [
        "action.devices.traits.OnOff",
        "action.devices.traits.FanSpeed"
      ],
      "name": {
        "defaultNames": [
          "Simple Connect Fan"
        ],
        "name": "Livingroom Fan",
        "nicknames": [
          "Simple Connect Fan"
        ]
      },
      "willReportState": true,
      "attributes": {
        "availableFanSpeeds": {
          "speeds": [
            {
              "speed_name": "S0",
              "speed_values": [
                {
                  "speed_synonym": [
                    "stopped",
                    "speed 0"
                  ],
                  "lang": "en"
                }
              ]
            },
            {
              "speed_name": "S1",
              "speed_values": [
                {
                  "speed_synonym": [
                    "low",
                    "speed 1"
                  ],
                  "lang": "en"
                }
              ]
            },
            {
              "speed_name": "S2",
              "speed_values": [
                {
                  "speed_synonym": [
                    "medium",
                    "speed 2"
                  ],
                  "lang": "en"
                }
              ]
            },
            {
              "speed_name": "S3",
              "speed_values": [
                {
                  "speed_synonym": [
                    "high",
                    "speed 3"
                  ],
                  "lang": "en"
                }
              ]
            }
          ],
          "ordered": true
        },
        "reversible": false
      },
      "deviceInfo": {
        "manufacturer": "company",
        "model": "test"
      },
      "customData": {
        "speedType": 3
      }
    },
    {
      "id": "123-Light",
      "type": "action.devices.types.LIGHT",
      "traits": [
        "action.devices.traits.OnOff",
        "action.devices.traits.Brightness"
      ],
      "name": {
        "defaultNames": [
          "Simple Connect Light"
        ],
        "name": "Livingroom Light",
        "nicknames": [
          "Simple Connect LIGHT"
        ]
      },
      "willReportState": true,
      "attributes": {
        "commandOnlyOnOff": false
      },
      "deviceInfo": {
        "manufacturer": "company",
        "model": "test"
      }
    }
  ]
}
}

Report State JSON object:

{
  "requestId": "11859327534344019896",
  "agentUserId": "123456789",
  "payload": {
    "devices": {
      "states": {
        “123-Fan": {
          "online": true,
          "on": false,
          "currentFanSpeedSetting": "S3"
        },
        “123-Light": {
          "online": true,
          "on": false,
          "brightness": 70
        }
      }
    }
  }
}
Fei Deng
  • 3
  • 1

1 Answers1

0

I'm getting the error 404 on the first time Report State after SYNC, which causes Account Linking failed.

These two things should not be directly linked. The account linking flow should succeed if:

  1. Google successfully receives an OAuth access token
  2. Initial SYNC intent is successful
  3. Initial QUERY intent is successful

Whether or not you are able to successfully call Report State should not cause account linking to fail. It would be because of an error in one of the above steps.

Regarding the 404 error itself, this is likely a timing issue. Until the above linking process is complete, the agentUserId and corresponding device IDs are not yet written to Home Graph. If the API call comes in too soon, this would cause a 404 error.

For the account linking process, however, this is not necessary. The initial QUERY intent sent during the above flow accomplishes the same end populating the initial state in Home Graph. Our Report State guide was recently updated to reflect this change:

Following the initial SYNC for a device, the platform sends a QUERY intent that gathers the state of the device to populate Home Graph. After that point, Home Graph only stores the state that is sent with Report State.

You should determine if you can get account linking to succeed without making an initial call to Report State.

devunwired
  • 62,780
  • 12
  • 127
  • 139
  • thanks for your detailed info, I agree Account Linking does not need pass the first time of Report State based on the latest updates. The real concern for me is the inconsistency of the action. This issue starts happening after a few times of succeed account linking. I can get the succeed SYNC and the following QUERY as what you mentioned above, but the message "Could not update setting. Check your connection" pops up, the devices are connected successfully sometimes. – Fei Deng May 12 '20 at 23:30
  • Do you see anything in your [project error logs](https://developers.google.com/assistant/smarthome/develop/error-logging) when that happens? Something like `OPEN_AUTH_FAILURE`, `DEADLINE_EXCEEDED`, or an error parsing the intent responses? – devunwired May 13 '20 at 04:51