0

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.

Sharvin26
  • 2,741
  • 2
  • 9
  • 15

1 Answers1

0

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
        },
      }
    }
  }
}
Nick Felker
  • 11,536
  • 1
  • 21
  • 35
  • So According to my understanding the Pending Status will keep the Home graph open and once the actuation is perfomed on end device we can send the report state. Okay So this can be done for all the trait and this report state should this be sent from the Partner cloud or the web hook? Just a little bit confusion between it. – Sharvin26 Nov 30 '18 at 05:25
  • 1
    You should return a pending response as soon as possible from the webhook. Once your task is complete, you can report the state through your cloud. – Nick Felker Nov 30 '18 at 08:23
  • Thanks and In case of Query Intent there is no Status in response. So in that case How can I make Query Intent Asynchronous. And is there any timeout like if HomeGraph didn't recieve the report from the cloud within that time it should fire a error? – Sharvin26 Nov 30 '18 at 09:50
  • Also Sir I tried the Above Response with Pending { "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["123"], "status": "PENDING", "states": { "on": false, "online": true } }] } } But it's firing giving me turning on the light and then giving me the status. Is it compulsory to enable HomeGraph for this status to be pending from the GCP or it works without enabling. Because I haven't enable the HomeGraph. – Sharvin26 Nov 30 '18 at 10:06
  • After adding status as pending it's still working and not waiting for anything to be fired from my Manufacturer cloud – Sharvin26 Nov 30 '18 at 10:06
  • I think you might misunderstand. The response from your webhook is synchronous, and should be returned immediately. In your webhook, you can say the event succeeded completely, or it didn't complete yet. This should return as soon as possible and not wait. Later, you can send a changed state once you know the state changed. – Nick Felker Nov 30 '18 at 18:20
  • Thanks so basically this will be a Synchronous we cannot then response Asynchronous in this condition according to my understanding. – Sharvin26 Dec 01 '18 at 05:31
  • I think we have different interpretations of what asynchronous means. – Nick Felker Dec 01 '18 at 23:59
  • Think So. I had one more doubt I was trying to pass an HSV object for Color Query: "color": { "spectrumHsv": { "hue": 240.0, "saturation": 0.678, "value": 1.0 } } It's not working when I am saying "What color is the desk lamp?" – Sharvin26 Dec 05 '18 at 12:31
  • So you get a QUERY intent for your device with the [ColorSetting](https://developers.google.com/actions/smarthome/traits/colorsetting) trait, and you return that (presumably in a larger payload) and you get an error back? – Nick Felker Dec 05 '18 at 18:37
  • Yes, I return the payload as described in the document and I say "What color is the room led strip?" In that case, it starts giving me the Google search. Even in my Home control app for room led strip I can't see the color currently set for the device. All the other traits for Query Intent are working fine also Execute intent for the color is also working fine. – Sharvin26 Dec 06 '18 at 05:18