Skip to content

aandroide/google-actions-smarthome

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create your own smart devices

This project contains the code which demonstrates the integration of smart home devices with the Google Assistant
using a Firebase backend.

How to

Refer to the video below for step by step guidelines.

Detailed Youtube Video

  1. Go to the Actions on Google Developer Console.
  2. Click New Project, enter a name for the project, and click CREATE PROJECT.
  3. Select the Smart Home App.
  4. On the Overview screen in the Actions console, select Smart home.
  5. Choose the Smart home experience card, and you will then be directed to your project console.
  6. Download and install Node.js from https://nodejs.org/en/download/.
  7. To install the firebase CLI, run the following npm command from the terminal:
    sudo npm install -g firebase-tools   
    
  8. To verify that the CLI has been installed correctly, run:
    firebase --version     
    
  9. Authorize the Firebase CLI with your Google account by running:
    firebase login    
    
  10. Install git and clone the project using:
    sudo apt-get install git   
    git clone https://github.com/shivasiddharth/google-actions-smarthome   
    
  11. Change directory using:
    cd /google-actions-smarthome/smarthome-control/functions/   
    
  12. Navigate to the Google Cloud Console API Manager for your project id.
  13. Enable the HomeGraph API.
  14. Navigate to the Google Cloud Console API & Services page.
  15. Select Create Credentials and create a Service account key.
  16. Create a new Service account.
  17. Use the role Service Account > Service Account Token Creator.
  18. Create the account and download a JSON file. Save this in the functions folder as smart-home-key.json
  19. Connect to firebase using:
    firebase use <project-id>   
    
  20. Deploy firebase using:
    sudo npm install   
    firebase deploy   
    
  21. In the Actions console under Overview > Build your Action, select Add Action(s). Enter the URL for your cloud function that provides fulfillment for the smart home intents and click Save.
    https://us-central1-<project-id>.cloudfunctions.net/smarthome   
    
  22. On the Develop > Invocation tab, add a Display Name for your Action, and click Save. This name will appear in the Google Home app.
  23. To enable Account linking, select the Develop > Account linking option in the left navigation. Use these account linking settings:
    Client ID               : ABC123   
    Client secret           : DEF456
    Authorization URL       : https://us-central1-<project-id>.cloudfunctions.net/fakeauth  
    Token URL               : https://us-central1-<project-id>.cloudfunctions.net/faketoken   
    
  24. Click Save to save your account linking configuration, then click Test to enable testing on your project.
  25. To link to Google Assistant:
    1. On your phone, open the Google Assistant settings. Note that you should be logged in as the same account as in the console.
    2. Navigate to Google Assistant > Settings > Home Control (under Assistant).
    3. Select the plus (+) icon in the bottom right corner.
    4. You should see your test app with the [test] prefix and the display name you set.
    5. Select that item. The Google Assistant will then authenticate with your service and send a SYNC request, asking your service to provide a list of devices for the user.
  26. Now pre-programmed devices will appear in the Google Home app.

Pre-programmed smart devices

The codes in this project will create the following devices:

  1. 1 RGB light with brightness, color and on/off control.
  2. 1 Normal light with brightness and on/off control.
  3. 1 Fan with speed and on/off control (speed control trait is currently disabled by google hence the corresponding segments of codes have been commented out).
  4. 1 Thermostat with mode change and temperature control.
  5. 1 Temperature sensor device with temperature readout only.
  6. 1 Plug/Switch.

Adding or modifying the devices

  1. The devices have been declared for SYNC
  2. The QUERY for the corresponding devices
  3. The EXECUTE for the corresponding devices
  4. The REPORT STATE for the corresponding devices

Initialize devices by voice at first use, for example:

  1. OK Google, "Set thermostat to heat mode".
  2. Ok Google, "Set thermostat to 10 degrees".
  3. Ok Google, "Set lights to Green color".
  4. Ok Google, "Set light to 20% Brightness".

Note

  1. Do not install the json version 6 library as it is not currently compatible.
  2. Install the library Arduinojson vers:5.13.0
  3. Install the library Firebase Arduino from here: https://github.com/FirebaseExtended/firebase-arduino.git
  4. This project works with the core version esp8266 2.5.2

License

Copyright 2018 Google Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Releases

No releases published

Packages

No packages published

Languages

  • C++ 53.7%
  • JavaScript 46.3%