🏠How to build your own Actions on Google used to Google Homegraph (work with Google Assistant)
This sample is used to describe how to build your own backend service associated with Google Home Control.
There are all smart home references including all data schema and REST
API, RPC
API, etc.
This section will set up these setting for Google smart home
request :
OAuth 2.0
client id and client secret which is identify current request is come from Google
.OAuth 2.0
authorization endpoint which is used to distribute a authorization code for exchanging access token and refresh token.Your OAuth 2.0
token exchange endpoint which is used to exchange access token and refresh token via a authorization code which is come from authorization endpoint.
Your smart home
services fulfillment address, only support HTTPS
protocol.
You can follow this manual to create a Google actions
in the Actions console.
There are two kinds of deployment:
Deploy Smart Home
services to firebase functions
and firebase real-time database
. You should download your firebase-admin-sdk.json to functions/src/firebase-admin-sdk.json
before link to firebase real-time database.
frontend
is a dashboard for firebase real-time database.functions
is firebase cloud functions directory.
$ firebase login
$ firebase deploy
# All functionalities has been deployed on the firebase platform right now.
Deploy Smart Home
services to your own private server.
You should compile all Typescript
file to JavaScript
file first.
$ yarn tsc
Implement your own config/index.json
file.
{
"google_api_key": "access google homegraph"
}
Google api key
is used to access your own google homegraph service.
NOTICE: DO NOT commit config/index.json
with any secret key into your git.
Run deployment command
# deploy services
# Services is running at http://127.0.0.1:7001 by default
$ yarn deploy
# stop services
# shut down master worker work with cluster module (multi-process model)
$ yarn stop
You should follow these step to build this sample if you want that firebase works with a network proxy (More details: firebase/issues/155).
mutate the source code of faya-websocket
dependency (firebase-tools
dependents on it).
var Client = function(_url, protocols, options) {
options = options || {};
// add this proxy setting
options.proxy = {
origin: 'http://localhost:' + LOCAL_NETWORK_PROXY_PORT,
};
…
}
Export two variables
# eg:
# > export http_proxy=http://127.0.0.1:8000
$ export http_proxy=<the http address of network proxy, including network port>
# Optional step
$ export NODE_TLS_REJECT_UNAUTHORIZED=0
firebase login
without local server in your own shell
$ firebase login --no-localhost