2

I am implementing the local execution functionality for my google smart home action. I am following the steps in this link: https://developers.google.com/actions/smarthome/develop/local

I have already configured the scanning data in the console, and now I am trying to deploy my local execution app. I know how to program in javascript, I have created a couple of firebase functions, but I am not an expert in node.js. I don't understand how to setup and run this javascript app.

I tried to run it on the browser, but it says it cannot find "require", and I read that node.js is not supposed to run on client side. In the link above, it says to create an index.html, that declares the "local_execution.js". Is this javascript module going to run on client side? Can someone point me in the right direction? Maybe explain how to setup the app directory.

Thank you in advance, Henrique

1 Answers1

1

The best place to get started would be with the local home sample app on GitHub. This sample includes both a local execution app and a compatible virtual device, with instructions to get it compiled and deployed.

For testing, you need to host the web app (HTML/JavaScript) in a location that's accessible to your Home device. This could be a local dev server or something like Firebase Hosting (the sample has instructions for both). The hosted URL goes in the console under Test > On device testing.

I tried to run it on the browser, but it says it cannot find "require", and I read that node.js is not supposed to run on client side.

The Home devices run a browser-based (Chrome) environment, so your JavaScript must be compatible with the browser. If you use Node programming paradigms (e.g. importing modules using require) in your code, you need to use a bundler tool such as Webpack or Parcel to package the code for the browser. The sample uses Webpack to accomplish this.

Side Note: You can't run even a properly packaged local home app in the browser on your development machine because the local home SDK only exists on Home devices.

devunwired
  • 62,780
  • 12
  • 127
  • 139