简体   繁体   中英

How does Action on Google Smart Home API works Asynchronously?

I recently developed a project on Amazon Alexa for Smart Home Skill API and We developed using Async Method. In Alexa there are Event Gateway to make post call Asynchronously and deffered response to keep event gateway open. I know that Action on Google has homegraph. Working of HomeGraph and EventGateway is it the same I was wondering? I was also wondering how can I make the Execution Asynchronous for the Action on Google? According to my understanding I'll be requiring to make a post call to Homegraph for that purpose.

Yes, you can make a POST to the home graph once the state is completely changed.

For certain types of devices, which may take a while to complete, you can return an execute response with a PENDING:

{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "commands": [{
      "ids": ["123"],
      "status": "PENDING",
      "states": {
        "on": false,
        "online": true
      }
    }]
  }
}

Later, once the status is correct, you can use the Report State API:

{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "agentUserId": "1234",
  "payload": {
    "devices": {
      "states": {
        "123": {
          "on": true
        },
      }
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM