-
-
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).
- 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. Configuration of this server will take place in the appsettings.json
file.
The appsettings.json
file contains basic application setup that needs to happen.
Configuration Setting | Purpose |
---|---|
deviceConfigFile | File path to the Google Device configuration file. |
googleHomeAgentUserId | The unique ID to identify your application to Google Actions. |
googleHomeHomeGraphApiKey | Your Google Home Graph API key, used for REQUEST_SYNC calls. |
brokerIp | MQTT Broker IP address. |
brokerPort | MQTT Broker port, usually 1883. |
brokerUsername | MQTT Broker username, if applicable. |
brokerPassword | MQTT Broker password, if applicable. |
authority | The URL of your application. Used by the OAuth implementation to validate tokens have been issued from the internal OAuth server. |
requireSSL | Turn on/off the OAuth server requiring communication over SSL. |
clientId | The Client ID issued by your Actions to Google. |
clientSecret | The Client secret you will provide to the Goolge Actions config (Generating a GUID is sufficient). |
resourceName | The OAuth resource name. Can probably be left alone. |
subjectId | OAuth subject ID, basically only used internally, and can be any GUID. |
username | The username that you will login with during account linking in the Google Home App |
password | The password that you will login with during account linking in the Google Home App |
redirectUri | The "allowed" redirect URI to satisfy the OAuth server's security checks. Should be of the form "https://oauth-redirect.googleusercontent.com/r/YOUR_PROJECT_ID". |
signingCert.file | File path to an external certificate if you want to use your own cert for signing. Note, if null, the app will generate a cert at first run called "tempkey.rsa" in the app root |
signingCert.passPhrase | Pass phrase to use for decryption of signing cert private key, if needed |