1.0.20220805 • Published 2 years ago

@maxim_mazurok/gapi.client.homegraph v1.0.20220805

Weekly downloads
77
License
MIT
Repository
github
Last release
2 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

2 years ago

1.0.20220615

2 years ago

1.0.20220629

2 years ago

1.0.20220715

2 years ago

1.0.20220712

2 years ago

1.0.20220805

2 years ago

1.0.20220729

2 years ago

1.0.20220727

2 years ago

1.0.20220722

2 years ago

1.0.20220429

2 years ago

1.0.20220513

2 years ago

1.0.20220520

2 years ago

1.0.20220525

2 years ago

1.0.20220531

2 years ago

1.0.20220422

2 years ago

1.0.20220316

2 years ago

1.0.20220325

2 years ago

1.0.20220411

2 years ago

1.0.20220331

2 years ago

1.0.20220225

2 years ago

1.0.20220308

2 years ago

1.0.20220311

2 years ago

1.0.20211230

2 years ago

1.0.20220218

2 years ago

1.0.20220114

2 years ago

1.0.20220204

2 years ago

1.0.20220121

2 years ago

1.0.20220128

2 years ago

1.0.20220215

2 years ago

1.0.20211117

3 years ago

1.0.20211210

2 years ago

1.0.20211203

2 years ago

1.0.20211104

3 years ago

1.0.20211201

2 years ago

1.0.20211022

3 years ago

1.0.20211029

3 years ago

1.0.20211015

3 years ago

1.0.20211008

3 years ago

1.0.20210920

3 years ago

1.0.20210910

3 years ago

1.0.20210826

3 years ago

1.0.20210806

3 years ago

1.0.20210729

3 years ago

1.0.20210728

3 years ago

1.0.20210720

3 years ago

1.0.20210713

3 years ago

1.0.20210702

3 years ago

1.0.20210618

3 years ago

1.0.20210604

3 years ago

1.0.20210527

3 years ago

1.0.20210525

3 years ago

1.0.20210507

3 years ago

1.0.20210430

3 years ago

1.0.20210427

3 years ago

1.0.20210416

3 years ago

1.0.20210409

3 years ago

1.0.20210402

3 years ago

1.0.20210326

3 years ago

1.0.20210303

3 years ago

1.0.20210310

3 years ago

1.0.20210226

3 years ago

1.0.20210219

3 years ago

1.0.20210210

3 years ago

1.0.20210205

3 years ago

1.0.20210122

3 years ago

1.0.20210115

3 years ago

1.0.20210106

3 years ago

1.0.20201214

3 years ago

1.0.20201204

3 years ago

1.0.20201127

3 years ago

1.0.20201112

4 years ago

1.0.20201106

4 years ago