简体   繁体   中英

Is there a .NET client library for Google Smart Home Action?

I am building an endpoint to fulfill Google Smart Home Actions requests. I need to build this in ASP.NET Core. Is there a library I can use to wrap Google Smart Home Actions request? I am only seeing libraries for Node.js and Java.

Google Smart Home Actions libraries

There is not currently a fulfillment library for intent handling with .NET (although we are exploring the idea). However, you can use the Google APIs for .NET client library to communicate with the Home Graph service (used for features such as Request Sync and Report State).

Here is a quick example of what the Home Graph client would look like in C#:

try
{
    // Create authorized client
    GoogleCredential credential = GoogleCredential.FromFile("service-account.json")
        .CreateScoped(new[] { "https://www.googleapis.com/auth/homegraph" });
    var service = new HomeGraphServiceService(
        new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = "HomeGraphTester",
        });

    // Make Home Graph requests
    var request = new RequestSyncDevicesRequest{
      AgentUserId = "1234"
    };
    var response = service.Devices.RequestSync(request);
}
catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM