1

I need update devices, can I REQUEST_SYNC to do it?

here say this api is not public yet. what can i do?

eson
  • 21
  • 1

1 Answers1

1

You can get an API Key for the HomeGraph APIs. You make a call to their API endpoint with your API key:

https://homegraph.googleapis.com/v1/devices:requestSync?key=API_KEY

In the body, make sure you provide the agentUserId that you originally returned in your SYNC response. This will cause your endpoint to receive another SYNC call.

Here's a cURL command:

curl -i -s -k -X POST -H "Content-Type: application/json" -d "{agent_user_id: \"agentUserId\"}" "https://homegraph.googleapis.com/v1/devices:requestSync?key=API_KEY"

Check the new docs to learn a bit more about how it is used.

Nick Felker
  • 11,536
  • 1
  • 21
  • 35
  • Google seems to have enabled the Homegraph API in the developer console now... I can call it with an API key, but it seems to be undocumented, so I don't know what to call it with. I tried duplicating what was leaked in the node samples: https://github.com/actions-on-google/actionssdk-smart-home-nodejs – Michael Hallock Sep 23 '17 at 20:02
  • I am unaware that of any API visibility changing. I would not rely on the current APIs indefinitely as they may change or be unstable. – Nick Felker Sep 23 '17 at 21:07
  • REQUEST_SYNC is an operation of Google's Homegraph API, which was just recently enabled in the Google Cloud Console. You can now add it to your project, and use your API key to call it, as demonstrated in the commits to that repo I linked (later removed, you have to look at history). We can hit the endpoint, but dont have docs on what to send it yet. – Michael Hallock Sep 24 '17 at 22:26
  • Hey there, we just added the docs on how to use the feature. We'll be updating the sample soon. – Nick Felker Sep 30 '17 at 00:26
  • 1
    It's probably something wrong with the formatting of your payload. I've been testing it with the sample project and have gotten it to work consistently. Is it inside of your `payload` attribute? – Nick Felker Oct 01 '17 at 21:11
  • Deleted my other comment Nick, but thank you, that was it, I had the agentUserId outside the payload object. Working, and can trigger updates with REQUEST_SYNC now, thank you! – Michael Hallock Oct 01 '17 at 21:15
  • No problem. Just make sure you accept this answer so others will be able to see how this is done. – Nick Felker Oct 01 '17 at 21:23