jufab / smart-home-local

Local Home SDK sample

Home Page:https://developers.google.com/actions/smarthome/concepts/local

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Local Home SDK sample

This sample shows how to integrate with the Local Home SDK. The Local Home SDK allow developers to add a local path to execute smart home intents by running TypeScript (or JavaScript) directly on Google Home smart speakers and Nest smart displays.

Prerequisites

Run the sample

Set up the smart home project

Setup the virtual device

  • Open the smart home project in the Actions console, then perform these steps:
    • in Build > Actions > Smart home > Actions: Add the following attributes in the Device Scan Configuration:
      • UDP discovery address: 255.255.255.255
      • UDP discovery port in: 3312
      • UDP discovery port out: 3311
      • UDP discovery packet: A5A5A5A5
  • Start the virtual light strip server:
npm install --prefix device/
npm start --prefix device/ -- \
          --udp_discovery_port 3311 \
          --udp_discovery_packet A5A5A5A5 \
          --device_id fakecandy-0

This starts a server that replies to UDP discovery packets with device information and displays openpixelcontrol commands to the terminal in a colorful way. Note: The server needs to listen on the same local network as the Home device.

Deploy the sample app

Serve the sample app locally from the same local network as the Home device, or deploy it to a publicly reacheable URL endpoint.

Deploy locally

  • Start the local development server:
npm install --prefix app/
npm start --prefix app/ -- --host 0.0.0.0

Note: The local development server needs to listen on the same local network as the Home device in order to be able to load the Local Home SDK application.

Deploy to Firebase Hosting

npm run build --prefix app/
npm run deploy --prefix app/ -- --project FIREBASE_PROJECT_ID

Test the Local Home SDK application

  • Reboot the Google Home Device
  • Open chrome://inspect
  • Locate the Local Home SDK application and click inspect to launch the Chrome developer tools.
  • Try the following query
    • Turn on the light
    • Turn off the light
    • Set the light brightness to 50
    • Set the light color to magenta

Test and Lint

npm test --prefix app/
npm run lint --prefix device/

License

See LICENSE

About

Local Home SDK sample

https://developers.google.com/actions/smarthome/concepts/local

License:Apache License 2.0


Languages

Language:TypeScript 94.3%Language:JavaScript 4.9%Language:HTML 0.9%