google-home / smart-home-nodejs

A sample of the Smart Home device control APIs in Actions on Google
Apache License 2.0
888 stars 289 forks source link

Need help with reportState implementation #539

Closed nazbabu closed 3 years ago

nazbabu commented 3 years ago

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****

nazbabu commented 3 years ago

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 ?

Fleker commented 3 years ago

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.

nazbabu commented 3 years ago

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

proppy commented 3 years ago

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

nazbabu commented 3 years ago

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