Skip to content

How to deploy the service.

sogaani edited this page Jun 21, 2018 · 3 revisions

What is MozAssist.

The MozAssist is a Google Assistant smart home service that integrate with Gateway.

How to Deploy the MozAssist on your local.

Clone this project.

git clone https://github.com/sogaani/mozassist.git

Create a config file.

Create a file named config.staging.json with following text.

{
"clientId": "some text[0-9a-zA-Z]*",
"clientSecret": "some text[0-9a-zA-Z]*",
"redirectUrl": "fill later",
"googleServiceAccount": "fill later",
"homeGraphServiceAccount": "fill later",
"isLocal": true,
"mongodb": "fill later",
"smartHomeProviderApiKey": "not used currently"
}

Create your smart home action.

  1. In the Action Console. Create a new project and redirect to https://console.actions.google.com/project//onboarding.
  2. Select Home Control > Smart home
  3. Fill redirectUrl value on config.staging.json.
"redirectUrl": "https://oauth-redirect.googleusercontent.com/r/<google developer project ID>",

Enable Home Graph API.

Google Assistant smart home services use Home Graph API to store available devices and their states.

  1. Follow the directions from report-state to enable Home Graph API and get credentials.
  2. Fill homeGraphServiceAccount value on config.staging.json.
"homeGraphServiceAccount": <JSON format text downloaded above>,

Enable Cloud Firestore.

The MozAssist use Firestore as database to store oauth state, oauth token, and Gateway address.

  1. Go to firebase console.
  2. Select the project created above. Click the database. Enable Cloud Firestore Beta, and select lock mode.
  3. Go to Service Accounts. Click Generate new private key and get credentials.
  4. Fill googleServiceAccount value on config.staging.json.
"googleServiceAccount": <JSON format text downloaded above>,

Setup Mongodb. (optional)

The MozAssist use Mongodb and agenda to polling the devices properties and report the state. Setup the Mongodb and get the database uri.

"mongodb": {
  "uri": "mongodb://....
}

If not setup Mongod, the MozAssist response a device state with Query request.

Start MozAssist.

  1. Execute following commands on project root folder.
npm install
npm start
  1. You get a following text on console and remember the address placed after COPY & PASTE NGROK URL BELOW:.
|###################################################|
|                                                   |
|        COPY & PASTE NGROK URL BELOW:              |
|                                                   |
|          https://036f847c.ngrok.io                |
|                                                   |
|###################################################|

Setup your smart home project.

Access google actions console. Select the project created above.

Set your service Name.

Click Name your Smart Home action. Set a name what you want. Click save.

Account Linking.

  1. Click Setup account linking. Select No, I only want to allow account creation on my website and click next.
  2. Select Linking type to OAuth and Authorization code. Click next.
  3. Fill Client information as forllowing and click next.
    • Client ID issued by your Actions to Google: clientId value on config.staging.json.
    • Client secret: clientSecret value on config.staging.json.
    • Authorization URL: https://<your-service-address>/oauth
    • Token URL: https://<your-service-address>/token
  4. Fill Scopes as readwrite and click Next.
  5. Fill least one word to Testing instructions and click Save.

Build Actions

Click Add Action(s) > Add your first action. Fill Add fulfillment URL as https://<your-service-address>/smarthome and click DONE.

Start Test.

Click TEST.