0.0.20241025 • Published 8 months ago

@maxim_mazurok/gapi.client.homegraph-v1 v0.0.20241025

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

TypeScript typings for HomeGraph API v1

For detailed description please check documentation.

Installing

Install typings for HomeGraph API:

npm install @types/gapi.client.homegraph-v1 --save-dev

Usage

You need to initialize Google API client in your code:

gapi.load('client', () => {
  // now we can use gapi.client
  // ...
});

Then load api client wrapper:

gapi.client.load(
  'https://homegraph.googleapis.com/$discovery/rest?version=v1',
  () => {
    // now we can use:
    // gapi.client.homegraph
  }
);
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('homegraph', 'v1', () => {
  // now we can use:
  // gapi.client.homegraph
});

Don't forget to authenticate your client before sending any request to resources:

// declare client_id registered in Google Developers Console
var client_id = '',
  scope = [
    // Private Service: https://www.googleapis.com/auth/homegraph
    'https://www.googleapis.com/auth/homegraph',
  ],
  immediate = true;
// ...

gapi.auth.authorize(
  {client_id: client_id, scope: scope, immediate: immediate},
  authResult => {
    if (authResult && !authResult.error) {
      /* handle successful authorization */
    } else {
      /* handle authorization error */
    }
  }
);

After that you can use HomeGraph API resources:

/*
Unlinks the given third-party user from your smart home Action. All data related to this user will be deleted. For more details on how users link their accounts, see [fulfillment and authentication](https://developers.home.google.com/cloud-to-cloud/primer/fulfillment). The third-party user's identity is passed in via the `agent_user_id` (see DeleteAgentUserRequest). This request must be authorized using service account credentials from your Actions console project.
*/
await gapi.client.homegraph.agentUsers.delete({agentUserId: 'agentUserId'});

/*
Gets the current states in Home Graph for the given set of the third-party user's devices. The third-party user's identity is passed in via the `agent_user_id` (see QueryRequest). This request must be authorized using service account credentials from your Actions console project.
*/
await gapi.client.homegraph.devices.query({});

/*
Reports device state and optionally sends device notifications. Called by your smart home Action when the state of a third-party device changes or you need to send a notification about the device. See [Implement Report State](https://developers.home.google.com/cloud-to-cloud/integration/report-state) for more information. This method updates the device state according to its declared [traits](https://developers.home.google.com/cloud-to-cloud/primer/device-types-and-traits). Publishing a new state value outside of these traits will result in an `INVALID_ARGUMENT` error response. The third-party user's identity is passed in via the `agent_user_id` (see ReportStateAndNotificationRequest). This request must be authorized using service account credentials from your Actions console project.
*/
await gapi.client.homegraph.devices.reportStateAndNotification({});

/*
Requests Google to send an `action.devices.SYNC` [intent](https://developers.home.google.com/cloud-to-cloud/intents/sync) to your smart home Action to update device metadata for the given user. The third-party user's identity is passed via the `agent_user_id` (see RequestSyncDevicesRequest). This request must be authorized using service account credentials from your Actions console project.
*/
await gapi.client.homegraph.devices.requestSync({});

/*
Gets all the devices associated with the given third-party user. The third-party user's identity is passed in via the `agent_user_id` (see SyncRequest). This request must be authorized using service account credentials from your Actions console project.
*/
await gapi.client.homegraph.devices.sync({});
0.0.20241025

8 months ago

0.0.20241018

8 months ago

0.0.20240927

9 months ago

0.0.20241004

9 months ago

0.0.20241011

9 months ago

0.0.20240913

10 months ago

0.0.20240920

9 months ago

0.0.20240906

10 months ago

0.0.20240830

10 months ago

0.0.20240826

10 months ago

0.0.20240530

1 year ago

0.0.20240809

11 months ago

0.0.20240529

1 year ago

0.0.20240607

1 year ago

0.0.20240802

11 months ago

0.0.20240726

11 months ago

0.0.20240605

1 year ago

0.0.20240523

1 year ago

0.0.20240524

1 year ago

0.0.20240816

11 months ago

0.0.20240614

1 year ago

0.0.20240621

1 year ago

0.0.20240719

11 months ago

0.0.20240712

12 months ago

0.0.20240517

1 year ago

0.0.20240503

1 year ago

0.0.20240427

1 year ago

0.0.20240419

1 year ago

0.0.20240417

1 year ago

0.0.20240412

1 year ago

0.0.20240409

1 year ago

0.0.20240405

1 year ago

0.0.20240329

1 year ago

0.0.20240322

1 year ago

0.0.20240315

1 year ago

0.0.20240311

1 year ago

0.0.20240226

1 year ago

0.0.20240220

1 year ago

0.0.20240213

1 year ago

0.0.20240211

1 year ago

0.0.20240207

1 year ago

0.0.20240206

1 year ago

0.0.20240201

1 year ago

0.0.20240126

1 year ago

0.0.20240119

1 year ago

0.0.20240111

1 year ago

0.0.20240105

1 year ago

0.0.20231208

2 years ago

0.0.20231130

2 years ago

0.0.20230818

2 years ago

0.0.20230811

2 years ago

0.0.20231107

2 years ago

0.0.20231110

2 years ago

0.0.20230728

2 years ago

0.0.20230920

2 years ago

0.0.20230721

2 years ago

0.0.20230804

2 years ago

0.0.20231020

2 years ago

0.0.20230915

2 years ago

0.0.20231006

2 years ago

0.0.20230831

2 years ago

0.0.20230714

2 years ago

0.0.20231013

2 years ago

0.0.20230829

2 years ago

0.0.20230707

2 years ago

0.0.20230908

2 years ago

0.0.20231123

2 years ago

0.0.20230623

2 years ago

0.0.20230519

2 years ago

0.0.20230516

2 years ago

0.0.20230526

2 years ago

0.0.20230428

2 years ago

0.0.20230414

2 years ago

0.0.20230317

2 years ago

0.0.20230421

2 years ago

0.0.20230324

2 years ago

0.0.20230225

2 years ago

0.0.20230303

2 years ago

0.0.20230405

2 years ago

0.0.20230331

2 years ago

0.0.20230310

2 years ago

0.0.20230216

2 years ago

0.0.20230203

2 years ago

0.0.20230127

2 years ago

0.0.20230210

2 years ago

0.0.20230106

2 years ago

0.0.20221214

3 years ago

0.0.20221115

3 years ago

0.0.20221221

3 years ago

0.0.20230113

2 years ago

0.0.20221109

3 years ago

0.0.20221206

3 years ago

0.0.20221118

3 years ago

0.0.20221018

3 years ago

0.0.20221007

3 years ago

0.0.20221028

3 years ago

0.0.20221004

3 years ago

0.0.20221021

3 years ago

0.0.20220909

3 years ago

0.0.20220921

3 years ago

0.0.20220823

3 years ago

0.0.20220812

3 years ago

0.0.20220805

3 years ago