-
Notifications
You must be signed in to change notification settings - Fork 3
Infrastructure
These integration is created using Amazon Web Services using a complete serverless approach. API Gateway provide the HTTP endpoint for OAuth2 account linking and Google Smart Home Action fulfillment. Multiple Lambda function provide the bridge logic to map IoT Things as smart home devices.
In order to deploy this application you need an AWS account, if you don't have one register at AWS Console. All the application is described with a CloudFormation template, so is really easy to deploy it: just few clicks.
Application is organized into micro-services that communicate to each other with an synchronous interface (with API Gateway) and an asynchronous one (using EventBridge). Communication APIs are described using OpenAPI Specification (OAS) and stored in resources
directories in two file api.yaml
(API Gateway) and events.yaml
(EventBridge).
An API Gateway endpoint will serve the OAuth2 authentication required for account linking, no user will we managed, so you don't need to create accounts, reset password or some other complicated things. Of sure, keep your client ID and client secret for you, don't share it with anyone.
This service also expose an HTTP API to provide Bearer token validation, used by other services to validate the request.
API Gateway also provide the Google Smart Home Action fulfillment, protected with the OAuth2 authentication. Here Google will ask for device state, change it, ask for all devices to synchronize.
Alexa will directly use a Lambda function without using the API Gateway endpoint for the fulfillment, it will pass the access token directly into the Lambda event. This token will be checked before doing any operations to improve the security (also managed by a IAM role).
When one of the IoT Thing change the state outside this system you have to push a message into a specific SNS topic and a Lambda will automatically send this changes to Google Home or Alexa, this in order to trigger theirs routines. In the same way, when you change some IoT Thing attribute like name or type the devices list can be synchronize in the same way without disconnect and re-connect the integration.
Smart Home devices will be retrieved from your IoT Things list, a combination of attributes and tags allow you to map your Thing like an oven, a thermostat, a light, a switch or any other devices the smart home assistants support.
Google Home service expose an HTTP endpoint to respond to Google fulfillment requests (commands and state request) and a Lambda function that react to list device changes and their states reporting to HomeGraph API.
Alexa service creates a Lambda function, used by Alexa itself, that provided the requests fulfillment (commands and state request) and an other Lambda function that react to list device changes and their states reporting to Alexa Interface Message API.