0.0.20240503 • Published 14 days ago

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

Weekly downloads
-
License
MIT
Repository
github
Last release
14 days 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.20240503

14 days ago

0.0.20240427

19 days ago

0.0.20240419

28 days ago

0.0.20240417

1 month ago

0.0.20240412

1 month ago

0.0.20240409

1 month ago

0.0.20240405

1 month ago

0.0.20240329

2 months ago

0.0.20240322

2 months ago

0.0.20240315

2 months ago

0.0.20240311

2 months ago

0.0.20240226

3 months ago

0.0.20240220

3 months ago

0.0.20240213

3 months ago

0.0.20240211

3 months ago

0.0.20240207

3 months ago

0.0.20240206

3 months ago

0.0.20240201

4 months ago

0.0.20240126

4 months ago

0.0.20240119

4 months ago

0.0.20240111

4 months ago

0.0.20240105

4 months ago

0.0.20231208

5 months ago

0.0.20231130

6 months ago

0.0.20230818

9 months ago

0.0.20230811

9 months ago

0.0.20231107

6 months ago

0.0.20231110

6 months ago

0.0.20230728

10 months ago

0.0.20230920

8 months ago

0.0.20230721

10 months ago

0.0.20230804

10 months ago

0.0.20231020

7 months ago

0.0.20230915

8 months ago

0.0.20231006

7 months ago

0.0.20230831

9 months ago

0.0.20230714

10 months ago

0.0.20231013

7 months ago

0.0.20230829

9 months ago

0.0.20230707

10 months ago

0.0.20230908

8 months ago

0.0.20231123

6 months ago

0.0.20230623

11 months ago

0.0.20230519

12 months ago

0.0.20230516

1 year ago

0.0.20230526

12 months ago

0.0.20230428

1 year ago

0.0.20230414

1 year ago

0.0.20230317

1 year ago

0.0.20230421

1 year ago

0.0.20230324

1 year ago

0.0.20230225

1 year ago

0.0.20230303

1 year ago

0.0.20230405

1 year ago

0.0.20230331

1 year ago

0.0.20230310

1 year ago

0.0.20230216

1 year ago

0.0.20230203

1 year ago

0.0.20230127

1 year ago

0.0.20230210

1 year ago

0.0.20230106

1 year ago

0.0.20221214

1 year ago

0.0.20221115

2 years ago

0.0.20221221

1 year ago

0.0.20230113

1 year ago

0.0.20221109

2 years ago

0.0.20221206

1 year ago

0.0.20221118

1 year ago

0.0.20221018

2 years ago

0.0.20221007

2 years ago

0.0.20221028

2 years ago

0.0.20221004

2 years ago

0.0.20221021

2 years ago

0.0.20220909

2 years ago

0.0.20220921

2 years ago

0.0.20220823

2 years ago

0.0.20220812

2 years ago

0.0.20220805

2 years ago