-
-
Notifications
You must be signed in to change notification settings - Fork 29
Home
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.
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:
- 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.
- State topics are retained. This allows the app to bootstrap its internal state representation.
- 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.
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.
When setting up the "Account linking" in the "Actions on Google" console, follow these instructions.
- Select "OAuth" and "Authorization Code".
- "Client ID" to the same value used in the config file for oauth.clientId.
- "Client secret" to the same value used in the config file for oauth.clientSecret.
- "Authorization URL" to your public URL of your application + "/connect/authorize".
- "Token URL" to your public URL of your application + "/connect/token".
- "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".
See Setup.