0

I was reading your details and hoping that you may help me in my issue.

I have a google home at my home and some of the wifi bulbs & smoke sensor is connected to this, please note that i have not built these devices, i just bought them from market and just connected to the google home.

now I am creating a .net web application which can interact with google home to get the list of all devices with the status of the devices.

I have created a project in .net web application and trying to connect the google home via Google Graph API.

I have already done below steps:

  1. I have created a project in https://console.cloud.google.com/ also have setup consent screen, also a service account with KEY and downloaded the the credential json file locally,

  2. Setup scopes but it seems google graph scopes are not available at https://console.cloud.google.com/, so using smart management scops.

  3. Using Oauth 2.0 at time of getting consent from user(in my case its me).

  4. at the time of consent i am getting a code from google which i am using to get the access Token

CODE: ``` public async Task GetToken(string code) { var flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer { ClientSecrets = new ClientSecrets { ClientId = ClientId, ClientSecret = ClientSecret }, Scopes = Scopes, //Scopes = new[] { "https://www.googleapis.com/auth/sdm.service" }, DataStore = new FileDataStore("TokenFolder") });

        var token = await flow.ExchangeCodeForTokenAsync("user", code, redirectUri, CancellationToken.None);
        return token;
    }

5. I am using below code to create Credentials from my service account file which were saved at credentialsPath:
     
 ```     GoogleCredential credential;
         using (var stream = new FileStream(CredentialsPath, FileMode.Open, FileAccess.Read))
         {
             credential = GoogleCredential.FromStream(stream).CreateScoped(Scopes);
         }
  1. I am using below code to create service instance by passing credentials.
          {
              HttpClientInitializer = credential,
              ApplicationName = "Name of my application which i created in https://console.cloud.google.com/, "
          });

I am now confused what to call from my service to get the list of all devices connected to google home. i tried to use intent types: SYNC, QUERY but it seems QUERY require AgentuserID which i am not sure what to pass?

NOTE: I have not created any ACTION in https://console.actions.google.com/ I was big confused while setting up Actions because it was asking me fulfilments url and other details which i am not aware of. as my application does not have any fulfillment endpoints.

It would be great help if someone can help on this matter. any video or any github code would really help.

1 Answers1

2

Google provides two sets of APIs for smart home controls:

Smart Home APIs (SYNC, QUERY, EXECUTE) you are mentioning are for device manufacturers, allowing to provide voice control capabilities through Google surfaces for your own devices. It requires an already existing path to access and control devices by other means.

Device Access Web API is for service providers to fetch and control Google Nest devices through HTTP calls (REST API), but there is no way to interact with third-party devices connected through this API.

There is a third API called Google Home APIs under development right now, which is announced at Google IO'23 earlier this year. It allows mobile apps to interact with third-party devices connected to Google Accounts. You can find more about it in our IO'23 Highlights page, or fill out the developer preview survey to try it out.

Yiğit
  • 43
  • 4