0

I'm doing test suite.Refer to the test suite flow chart picture. Developer cloud can receive instructions sent by Google assistant. But when I do reportstate to homegraph, I get this exception. I don't know why?

I refer to this website https://developers.google.com/assistant/smarthome/develop/request-sync Step. Enable the Google homegraph API, create a service account key, and finally, call the API.

private void onDeviceAdded() throws IOException {
  FileInputStream stream = new FileInputStream("service-account-key.json");
  GoogleCredentials credentials = GoogleCredentials.fromStream(stream);
  mySmartHomeApp.setCredentials(credentials);

  RequestSyncDevicesResponse response = mySmartHomeApp.requestSync("my-self-user-id");
}

Exception i got:

io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
    at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:233)
    at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:214)
    at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:139)
    at com.google.home.graph.v1.HomeGraphApiServiceGrpc$HomeGraphApiServiceBlockingStub.requestSyncDevices(HomeGraphApiServiceGrpc.java:406)

exception img i got

Test Suite flow chart

Nick Felker
  • 11,536
  • 1
  • 21
  • 35

1 Answers1

0

There seems to be an issue with how your service is calling the API.

You may want to look at calling the gRPC methods directly from your application and be sure you have the correct agentUserId and service account key.

The implementation from the library call is pasted below:

val channel = ManagedChannelBuilder.forTarget("homegraph.googleapis.com").build()

val blockingStub = HomeGraphApiServiceGrpc.newBlockingStub(channel)
    // See https://grpc.io/docs/guides/auth.html#authenticate-with-google-3.
    .withCallCredentials(MoreCallCredentials.from(this.credentials))

val request = HomeGraphApiServiceProto.RequestSyncDevicesRequest.newBuilder()
    .setAgentUserId(agentUserId)
    .build()

return blockingStub.requestSyncDevices(request)
Nick Felker
  • 11,536
  • 1
  • 21
  • 35