google-home/smart-home-nodejs

Need help with reportState implementation

Closed this issue · 5 comments

I'm trying to implement reportState in NodeJs as per the "https://developers.google.com/assistant/smarthome/develop/report-state" documentation. But getting error that the reportState Home graph methods are deprecated in Node.js. Attaching the screenshot of the error details. Please guide what I'm doing wrong here
image
image****

I'm getting "SmartHomeApp.reportState Home Graph wrapper method is deprecated. Use Google APIs Node.js Client for Home Graph: https://www.npmjs.com/package/@googleapis/homegraph". Any idea why I'm getting this error ?

The current reportState function will continue to work, but migrating to the separate HomeGraph dependency is recommended as it uses a different implementation that scales better and will be automatically kept up-to-date with the updates to the underlying service definition.

The message is not an error, but more of a warning that migration is recommended when you have time.

Could you please point me to a sample implementation of reportState with new implementation?

The docs have been updated to showcase the new client:
https://developers.google.com/assistant/smarthome/develop/report-state#node.js

How to get the Auth working ?
Tried
const {google} = require('googleapis');
const homegraph = google.homegraph('v1');

const homegraphClient = homegraph({
version: 'v1',
auth: new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/homegraph'
})
});

Now I'm getting following error
TypeError: google.homegraph is not a function