AWS Lambda


The aws_lambda notification platform enables invoking AWS Lambda functions.

Setup

For more information, please read the AWS General Reference regarding Security Credentials to get the needed details. Also, check the boto3 Documentation about the profiles and the AWS Regions and Endpoints Reference for available regions.

Configuration

To use this notification platform in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
notify:
  - name: NOTIFIER_NAME
    platform: aws_lambda
    aws_access_key_id: AWS_ACCESS_KEY_ID
    aws_secret_access_key: AWS_SECRET_ACCESS_KEY
    region_name: 'us-east-1'

Configuration Variables

aws_access_key_id

(string)(Required if Aws_secret_access_key Is Provided)Your AWS Access Key ID. If provided, you must also provide an aws_secret_access_key and must not provide a profile_name.

aws_secret_access_key

(string)(Required if Aws_access_key_id Is Provided)Your AWS Secret Access Key. If provided, you must also provide an aws_access_key_id and must not provide a profile_name.

profile_name

(string)(Optional)A credentials profile name.

region_name

(string)(Required)The region identifier to connect to.

Default value: us-east-1

name

(string)(Optional)Setting the optional parameter name allows multiple notifiers to be created. The notifier will bind to the service notify.NOTIFIER_NAME.

Default value: notify

context

(string)(Optional)An optional dictionary you can provide to pass custom context through to the Lambda function. The context dictionary (if any) is combined with the same data available at the /api/config HTTP API route.

Usage

AWS Lambda is a notify platform and thus can be controlled by calling the notify service as described here. It will invoke a Lambda for all targets given in the notification payload. A target can be formatted as a function name, an entire ARN (Amazon Resource Name) or a partial ARN. For more information, please see the boto3 docs.

The Lambda event payload will contain everything passed in the service call payload. Here is an example payload that would be sent to Lambda:

{
  "title": "Test message!",
  "target": "arn:aws:lambda:us-east-1:123456789012:function:ProcessKinesisRecords",
  "data": {
    "test": "okay"
  },
  "message": "Hello world!"
}

The context will look like this:

{
  "hass": {
    "components": ["recorder", "logger", "http", "logbook", "api", "frontend"],
    "latitude": 44.1234,
    "location_name": "Home",
    "longitude": 5.5678,
    "unit_system": "metric",
    "time_zone": "Europe/Zurich",
    "version": "0.20.0.dev0"
  },
  "custom": {
    "two": "three",
    "test": "one"
  }
}