All Projects → actions-on-google → Smart Home Local

actions-on-google / Smart Home Local

Licence: apache-2.0
Local Home SDK sample

Programming Languages

typescript
32286 projects

Labels

Projects that are alternatives of or similar to Smart Home Local

Alexa Rubykit
Amazon Echo Alexa's App Kit Ruby Implementation
Stars: ✭ 155 (-8.28%)
Mutual labels:  iot
Ot Br Posix
OpenThread Border Router, a Thread border router for POSIX-based platforms.
Stars: ✭ 161 (-4.73%)
Mutual labels:  iot
Nrf52832 Mdk
An Open Source, Micro Development Kit for IoT Embedded Applications using the nRF52832 SoC
Stars: ✭ 166 (-1.78%)
Mutual labels:  iot
Ttn Esp32
The Things Network device library for ESP32 (ESP-IDF) and SX127x based devices
Stars: ✭ 156 (-7.69%)
Mutual labels:  iot
Home assistant files
Here are my Home Assistant configuration files
Stars: ✭ 159 (-5.92%)
Mutual labels:  iot
Pando Cloud
pando open source iot cloud.
Stars: ✭ 162 (-4.14%)
Mutual labels:  iot
Temper Esp8266
Temper is a compact temperature sensor based on ESP8266 and SHT30 with large 13x7 pixel led display.
Stars: ✭ 155 (-8.28%)
Mutual labels:  iot
Azuremapscodesamples
A set of code samples for the Azure Maps web control.
Stars: ✭ 167 (-1.18%)
Mutual labels:  iot
Feature Requests
ESPHome Feature Request Tracker
Stars: ✭ 160 (-5.33%)
Mutual labels:  iot
Angular Web Bluetooth
The missing Web Bluetooth module for Angular
Stars: ✭ 164 (-2.96%)
Mutual labels:  iot
Mqtt Pwn
MQTT-PWN intends to be a one-stop-shop for IoT Broker penetration-testing and security assessment operations.
Stars: ✭ 156 (-7.69%)
Mutual labels:  iot
Blockchain Samples
Samples demonstrating the use of Blockchain with IBM Watson IoT
Stars: ✭ 158 (-6.51%)
Mutual labels:  iot
Repo 2018
Deep Learning Summer School + Tensorflow + OpenCV cascade training + YOLO + COCO + CycleGAN + AWS EC2 Setup + AWS IoT Project + AWS SageMaker + AWS API Gateway + Raspberry Pi3 Ubuntu Core
Stars: ✭ 163 (-3.55%)
Mutual labels:  iot
Entity Controller
Entity and lighting controller for managing devices via timers, scripts, and sun-based time restrictions.
Stars: ✭ 156 (-7.69%)
Mutual labels:  iot
Esp32 Mqtt
ESP32 MQTT sample project for
Stars: ✭ 166 (-1.78%)
Mutual labels:  iot
Arduino Device Lib
Arduino Library for TTN Devices
Stars: ✭ 155 (-8.28%)
Mutual labels:  iot
Designiot
教你设计物联网系统。构建自己的Internet of Things 。
Stars: ✭ 1,983 (+1073.37%)
Mutual labels:  iot
Wasm Micro Runtime
WebAssembly Micro Runtime (WAMR)
Stars: ✭ 2,440 (+1343.79%)
Mutual labels:  iot
Makingfunxyz Esp8266
个人ESP8266学习笔记。
Stars: ✭ 167 (-1.18%)
Mutual labels:  iot
Introduction To Node.js
This training course will help you discover how the Node framework can help you write server-side code and build lightweight, scalable network applications. The course is an open source and covering everything from the basics of using JavaScript and Node.js to how to use it with cloud services like Azure Service Bus, Web sites and even in IoT scenarios.
Stars: ✭ 162 (-4.14%)
Mutual labels:  iot

Local Home SDK Sample

This sample demonstrates integrating a smart home Action with the Local Home SDK. The Local Home SDK allow developers to add a local path to handle smart home intents by running TypeScript (or JavaScript) directly on Google Home smart speakers and Nest smart displays. The sample supports the following protocols along with the companion virtual device:

  • Device Discovery: UDP, mDNS or UPnP
  • Control: UDP, TCP, or HTTP

Prerequisites

Configure the Actions project

Note: This project uses Cloud Functions for Firebase, which requires you to associate a billing account with your project. Actions projects do not create a billing account by default. See Create a new billing account for more information.

  • Create a new Smart Home project in the Actions console
  • Deploy the placeholder smart home provider to Cloud Functions for Firebase using the same Project ID:
    npm install --prefix functions/
    npm run firebase --prefix functions/ -- use ${PROJECT_ID}
    npm run deploy --prefix functions/
    
  • In Develop > Actions, set the following configuration values that matches the Cloud Functions for Firebase deployment:
    • Fulfillment: https://${REGION}-${PROJECT_ID}.cloudfunctions.net/smarthome
  • In Develop > Account linking, set the following configuration values:
    • Linking type: OAuth / Authorization code
    • Client ID:: placeholder-client-id
    • Client secret: placeholder-client-secret
    • Authorization URL: https://${REGION}-${PROJECT_ID}.cloudfunctions.net/authorize
    • Token URL: https://${REGION}-${PROJECT_ID}.cloudfunctions.net/token

Select a discovery protocol

Choose one of the supported the discovery protocols that you would like to test, and enter its attributes in the Actions console at Develop > Actions > Configure local home SDK under Device Scan Configuration.

Note: These are the default values used by the virtual device for discovery. If you choose to use different values, you will need to supply those parameters when you set up the virtual device.

UDP

  • Broadcast address: 255.255.255.255
  • Discovery packet: A5A5A5A5
  • Listen port: 3312
  • Broadcast port: 3311

mDNS

  • mDNS service name: _sample._tcp.local

  • Name: .*\._sample\._tcp\.local

    Note: The Name attribute value is a regular expression.

UPnP

  • UPNP service type: urn:sample:service:light:1

Select a control protocol

Choose one of the supported control protocols that you would like to test. You will use this value to configure both the cloud fulfillment and the virtual device.

  • UDP: Send execution commands to the target device as a UDP payload.
  • TCP: Send execution commands to the target device as a TCP payload.
  • HTTP: Send execution commands to the target device as an HTTP request.

Choose a device type

The local fulfillment sample supports running as a single end device or a hub/proxy device. This is determined by the number of channels you configure. A device with more than one channel will be treated as a hub by the local fulfillment sample code.

Set up cloud fulfillment

Configure the cloud service to report the correct device SYNC metadata based on your chosen device type and control protocol. Here are some examples for configuring the service for different use cases:

  • Report a single device (strand1) controlled via UDP commands:

    npm run firebase --prefix functions/ -- functions:config:set \
        strand1.leds=16 strand1.channel=1 \
        strand1.control_protocol=UDP
    npm run deploy --prefix functions/
    
  • Report three individual light strands connected through a proxy (hub1) and controlled via HTTP commands:

    npm run firebase --prefix functions/ -- functions:config:set \
        hub1.leds=16 hub1.channel=1,2,3 \
        hub1.control_protocol=HTTP
    npm run deploy --prefix functions/
    

After you have deployed the cloud configuration, trigger a new SYNC request from Google Assistant by unlinking and re-adding the placeholder smart home provider in the Google Home app.

Set up the virtual device

The companion virtual device is a Node.js app that emulates strands of RGB LEDs controllable using the Open Pixel Control protocol and displays the results to the terminal in a colorful way.

  • Virtual device discovery settings must match the attributes provided in Device Scan Configuration in Develop > Actions > Configure local home SDK.
    • If you modify the attributes in your Device Scan Configuration, you must configure the virtual device accordingly. See the virtual device README for more details on configuring the discovery attributes.
  • Virtual device control protocol should match control_protocol used with functions:config:set when setting up cloud fulfillment.
  • Configure the device type as end device or hub/proxy based on the number of --channel parameters provided. A device with more than one channel will be treated as a hub.

Note: The virtual device needs to listen on the same local network as the Home device.

Here are some examples for configuring the virtual device for different use cases:

  • Start the virtual device as a single device (strand1) discovered via UDP broadcast and controlled with UDP commands:

    npm install --prefix device/
    npm start --prefix device/ -- \
        --device_id strand1 \
        --discovery_protocol UDP \
        --control_protocol UDP \
        --channel 1
    
  • Start the virtual device as a hub (hub1) discovered via mDNS and controlling three individual strands with HTTP commands:

    npm install --prefix device/
    npm start --prefix device/ -- \
        --device_id hub1 \
        --discovery_protocol MDNS \
        --control_protocol HTTP \
        --channel 1 \
        --channel 2 \
        --channel 3
    

Note: See the virtual device README for more details on the supported configuration options.

Deploy the local execution 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/
    

    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.

  • Go to the smart home project in the Actions console

  • In Develop > Actions > On device testing set the Chrome and Node development URLs to the ones displayed in the local development server logs.

Deploy to Firebase Hosting

npm install --prefix app/
npm run build --prefix app/
npm run deploy --prefix app/ -- --project ${FIREBASE_PROJECT_ID}
  • Go to the smart home project in the Actions console
  • In Develop > Actions > On device testing set the development URLs to
    • Chrome: http://${FIREBASE_PROJECT_ID}.firebaseapp.com/web/index.html
    • Node: http://${FIREBASE_PROJECT_ID}.firebaseapp.com/node/bundle.js

Test the local execution app

  • 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
    • Set the light color to magenta
  • It should display the light strand(s) in a colorful way:
    ◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉
    

Test and Lint

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

License

See LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].