This contains a fully functioning OpenHAB cloud service designed to work with Actions on Google. This can be used with a Actions Console project to create an Action interface.
See the developer guide and release notes at https://developers.google.com/actions/ for more details.
Clone the project:
git clone https://github.com/RayBa82/openhab-assistant.git
cd openhab-assistant
- Use the Actions on Google Console to add a new project with a name of your choosing and click Create Project.
- Select Home Control, then click Smart Home.
- On the left navigation menu under SETUP, click on Invocation.
- Add your App's name. Click Save.
- On the left navigation menu under DEPLOY, click on Directory Information.
- Add your App info, including images, a contact email and privacy policy. This information can all be edited before submitting for review.
- Click Save.
The Request Sync feature allows a cloud integration to send a request to the Home Graph
to send a new SYNC request. The Report State feature allows a cloud integration to proactively
provide the current state of devices to the Home Graph without a QUERY
request. These are
done securely through JWT (JSON web tokens).
- Navigate to the Google Cloud Console API Manager for your project id.
- Enable the HomeGraph API.
- Navigate to the Google Cloud Console API & Services page
- Select Create Credentials and create a Service account key
- Create a new Service account
- Use the role Service Account > Service Account Token Creator
- Create the account and download a JSON file.
Save this as
src/smart-home-key.json
.
- Run
npm install
- Run
npm run build
You can deploy directly to Google App Engine by running
npm run deploy
. If you do, you will first need the gcloud CLI.
- Run
npm run build
. - Run
npm run start:local
.
You'll need to create OAuth credentials to enable API access.
- Visit the Credentials Page
- Select "Create Credentials" -> "OAuth client id"
- Select Web Application and give it a name. I left the restrictions open.
- Copy the client id and the client secret, you'll need these in the next step.
- Select your existing "Actions on Google" project
- Select "Smart Home Actions".
- If using Google App Engine, the URL will be https://{project-id}.appspot.com/smarthome
- Fill out all the App information. Feel free to use fake data and images, you're not actually going to submit this.
- Move on to Account linking.
* Select Authorization Code
* Enter the client ID and client secret from the OAuth Credentials you created earlier
* Authorization URL should be something like:
https://openhab.myserver.com/oauth2/authorize
* Token URL should be something likehttps://openhab.myserver.com/oauth2/token
* Set the scope togoogle-assistant
. This links to the records you will insert into the MongoDB tableoauth2scopes
later in Setup your Database step below. * Testing instructions: "None" - Hit save. You're not actually going to submit this for testing, we just need to set it up so we can deploy it later.
- SSH into to your openHAB Cloud instance
- Open the mongodb client
mongo
and enter these commands
use openhab
db.oauth2clients.insert({ clientId: "<CLIENT-ID>", clientSecret: "<CLIENT SECRET>"})
db.oauth2scopes.insert({ name: "any"})
db.oauth2scopes.insert( { name : "google-assistant", description: "Access to openHAB Cloud specific API for Actions on Google Assistant", } )
See LICENSE.