1.0.20220805 • Published 3 years ago

@maxim_mazurok/gapi.client.homegraph v1.0.20220805

Weekly downloads
77
License
MIT
Repository
github
Last release
3 years 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('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.google.com/assistant/smarthome/concepts/fulfillment-authentication). 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.google.com/assistant/smarthome/develop/report-state) for more information. This method updates the device state according to its declared [traits](https://developers.google.com/assistant/smarthome/concepts/devices-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.google.com/assistant/smarthome/reference/intent/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({  });
1.0.20220617

3 years ago

1.0.20220615

3 years ago

1.0.20220629

3 years ago

1.0.20220715

3 years ago

1.0.20220712

3 years ago

1.0.20220805

3 years ago

1.0.20220729

3 years ago

1.0.20220727

3 years ago

1.0.20220722

3 years ago

1.0.20220429

3 years ago

1.0.20220513

3 years ago

1.0.20220520

3 years ago

1.0.20220525

3 years ago

1.0.20220531

3 years ago

1.0.20220422

3 years ago

1.0.20220316

3 years ago

1.0.20220325

3 years ago

1.0.20220411

3 years ago

1.0.20220331

3 years ago

1.0.20220225

3 years ago

1.0.20220308

3 years ago

1.0.20220311

3 years ago

1.0.20211230

3 years ago

1.0.20220218

3 years ago

1.0.20220114

3 years ago

1.0.20220204

3 years ago

1.0.20220121

3 years ago

1.0.20220128

3 years ago

1.0.20220215

3 years ago

1.0.20211117

4 years ago

1.0.20211210

4 years ago

1.0.20211203

4 years ago

1.0.20211104

4 years ago

1.0.20211201

4 years ago

1.0.20211022

4 years ago

1.0.20211029

4 years ago

1.0.20211015

4 years ago

1.0.20211008

4 years ago

1.0.20210920

4 years ago

1.0.20210910

4 years ago

1.0.20210826

4 years ago

1.0.20210806

4 years ago

1.0.20210729

4 years ago

1.0.20210728

4 years ago

1.0.20210720

4 years ago

1.0.20210713

4 years ago

1.0.20210702

4 years ago

1.0.20210618

4 years ago

1.0.20210604

4 years ago

1.0.20210527

4 years ago

1.0.20210525

4 years ago

1.0.20210507

4 years ago

1.0.20210430

4 years ago

1.0.20210427

4 years ago

1.0.20210416

4 years ago

1.0.20210409

4 years ago

1.0.20210402

4 years ago

1.0.20210326

4 years ago

1.0.20210303

4 years ago

1.0.20210310

4 years ago

1.0.20210226

4 years ago

1.0.20210219

4 years ago

1.0.20210210

4 years ago

1.0.20210205

4 years ago

1.0.20210122

4 years ago

1.0.20210115

4 years ago

1.0.20210106

4 years ago

1.0.20201214

5 years ago

1.0.20201204

5 years ago

1.0.20201127

5 years ago

1.0.20201112

5 years ago

1.0.20201106

5 years ago