Skip to content
Michael Hallock edited this page Aug 19, 2018 · 16 revisions

HomeAutio.Mqtt.GoogleHome is a configurable bridge between MQTT and Google Actions Smart Home API fulfillment for home automation purposes. It allows someone to setup their own Smart Home Google Action fulfillment without the need for a cloud based service provider. It provides basic functionality of SYNC, QUERY, and EXECUTE intents, backed by MQTT. It also provides an OAuth implementation to fulfill that Google Action's requirement.

MQTT

All configuration is in the appsettings.json file as "broker" settings. Username and password can be null if not using authentication.

It makes some opinionated assumptions on how MQTT is used:

  1. Device command and state are represented as discrete topics (i.e., "device/blah/set" for changing state, and "device/blah" for reporting state). They don't have to follow this exact scheme, but the two topics must be discrete.
  2. State topics are retained. This allows the app to bootstrap its internal state representation.
  3. No complex payloads (i.e., JSON), only simple values. Devices publish multiple state / commands it supports as discrete topics.

When the app starts up, it will subscribe to all "state" topics in the config, and bootstrap its internal state based on any of those topics that are sent due to being "retained". These states will be monitored, and used to return responses for QUERY intents.

Any "EXECUTE" intents sent will find mapped "command" topics in the config to determine where to send updated values from Google Actions.

Note: If you can't guarantee the above MQTT assumptions talking directly to your device handlers, one would have to put something in between and publish to intermediate topics that "translate" to the device specific topics you need. This is beyond the scope of this project.

OAuth

This application contains a basic OAuth 2 server. All configuration is in the appsettings.json file as "oauth" settings. It implements the Authorization Code flow.

Google Action Account Linking

When setting up the "Account linking" in the "Actions on Google" console, follow these instructions.

  1. Select "OAuth" and "Authorization Code".
  2. "Client ID" to the same value used in the config file for oauth.clientId.
  3. "Client secret" to the same value used in the config file for oauth.clientSecret.
  4. "Authorization URL" to your public URL of your application + "/connect/authorize".
  5. "Token URL" to your public URL of your application + "/connect/token".
  6. "Scopes" to "api offline_access".

Note: The URLs are the ones exposed by this app. You will need to translate these as appropriate when proxying this app in nginx for SSL, etc. As an example, if your public URL is "https://test.com", and you are proxying this app in nginx as "/google", these URLs would be "https://test.com/google/connect/authorize" and "https://test.com/google/connect/token".

Configuration

See Setup.

Clone this wiki locally