1

As per Google Assistant documentation for Smart Home, the agentUserId used in action.devices.QUERY is defined to 'Reflects the unique (and immutable) user ID on the agent's platform. The string is opaque to Google, so if there's an immutable form vs a mutable form on the agent side, use the immutable form (e.g. an account number rather than email)'

However there can be cases where the same device (with same agent user id) is attached to multiple Google Assistant accounts and in such cases a DISCONNECT request may result is ceasing report state for all accounts. The solution will be to add some unique ID corresponding to the Google Assistant account, however such information is not available in any request.

Has anyone seen similar issue and is my understanding incorrect?

Zac
  • 162
  • 2
  • 10

1 Answers1

3

The agentUserId is meant to be the user account on the smart home platform. SHP user '1234' may have a vacuum and two lights, but could be linked to multiple Google accounts.

During the account linking process, you would be expected to give a refresh and access tokens to allow for Google to have authorized control over these devices. If you assign unique access tokens for each Google account that signs in, you'd be able to determine which Google account the request is coming from.

At that point, once the user disconnects, you can use the access token in the request header to associate that with a specific Google account and only disable reporting for that account while not affecting other accounts.

So, yes the solution is to have a unique ID connecting to the account. While this is not passed in the agent ID, there is already a mechanism to make this association through the authorization system.

Alternatively, you could append a key in the agentUserId, ie. '1234-user@gmail.com'. However, this may have unintended impacts in the Home Graph. In a multi-user home, you may end up seeing the devices duplicated because Google doesn't have the right information to deduplicate.

Nick Felker
  • 11,536
  • 1
  • 21
  • 35
  • The access token keeps changing and they are managed by a different system altogether. Implementing another service to keep track of such token changes does not seems to be easy and will be a work around to the problem. Are there any drawbacks in sending a unique id connecting Google account? If not can we add it to the request? – Zac Apr 14 '20 at 07:43
  • The drawback is that you'll end up with duplicate items in a multi-person environment. If myself and my roommate have connected the service to our Google account, any shared devices like smart speakers will imagine each of us have unique devices. – Nick Felker Apr 14 '20 at 22:15
  • The unique id connecting Google account will only be used and useful for the DISCONNECT intent and is not for actually identifying the device. Device identification can still continue using the agent user id. – Zac Apr 15 '20 at 04:11
  • A device ID is unique with respect to an agent user ID. If each Google account gets a unique agent user ID, each will get unique devices. – Nick Felker Apr 15 '20 at 15:50
  • I am referring to an additional Google account identification id (existing agent user id and device id may not be altered) which could be passed on each request. Controlling device, reporting state etc will still continue to use agent user id and device id. – Zac Apr 16 '20 at 13:45
  • This additional identification ID would be the access token. – Nick Felker Apr 16 '20 at 15:28
  • I hope the access token is for the agent user id and does not relate to the Google account, unless we build a relationship and track all the changes in token. – Zac Apr 16 '20 at 17:00
  • The access token is the identifier that binds together a Google account with an account on your side. – Nick Felker Apr 16 '20 at 21:14
  • I hope you understand the challenge in using the access token and how easy it would be, if there was some static Google account identifier instead. I believe this will be a challenge to others as well who are trying to handle such scenario. Hence request Google to consider adding a static identifier. – Zac Apr 17 '20 at 07:08