Skip to content

Commit

Permalink
Fix formatting and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MelleD committed May 13, 2024
1 parent 5f78438 commit 3dce727
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 34 deletions.
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ Please ⭐️ or sponsor this repo when you like it :heart:.

Also thanks to the amazing [Tailscale](https://www.home-assistant.io/integrations/tailscale/)integrations!

## Getting started


## Installation

### Getting started
Expand All @@ -37,23 +34,23 @@ Here are some steps you need to take. Since this guide is fairly new, please cre
The premise is that [Tailscale](https://www.home-assistant.io/integrations/tailscale/) Integration is installed in HA and the HA instance is available as a node.

1. The Git repo must be forked so that the Docker image for the AWS Lambda can be pushed to your private repository in the Amazon Elastic Container Registry.
1. Create a private repository on AWS [Amazon Elastic Container Registry](https://aws.amazon.com/de/ecr/). The name must be _ha-custom-lambda-tailscale_ for the repo
2. Create a private repository on AWS [Amazon Elastic Container Registry](https://aws.amazon.com/de/ecr/). The name must be _ha-custom-lambda-tailscale_ for the repo
<img alt="ecr-private" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/ecr_private.png">

See for more information [AWS Introduction ECR] (https://aws.amazon.com/de/ecr/getting-started/)

1. Create a keypair on AWS Identity Management (IM) to allow github action to push the Docker image to ECR.
3. Create a keypair on AWS Identity Management (IM) to allow github action to push the Docker image to ECR.
Create AWS_ACCESS_KEY_ID_ and _AWS_SECRET_ACCESS_KEY_
<img alt="Zugriff Schlüssel" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/zugriff_key.png">

See for more information [AWS Introduction credentials] (https://docs.aws.amazon.com/de_de/keyspaces/latest/devguide/access.credentials.html#SigV4_credentials)

Remember both carefully because the secret is only displayed once and is required in the next step.

1. Go to your forked repo under settings. Go to secrets and variables. Create two new secrets with _AWS_ACCESS_KEY_ID_ and _AWS_SECRET_ACCESS_KEY_ from the previous step
4. Go to your forked repo under settings. Go to secrets and variables. Create two new secrets with _AWS_ACCESS_KEY_ID_ and _AWS_SECRET_ACCESS_KEY_ from the previous step
<img alt="github secret" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/github_secret.png">

1. Then build and push the Docker image under Github Actions. To do this, run ```.github/workflows/docker-build-push.yml```
5. Then build and push the Docker image under Github Actions. To do this, run ```.github/workflows/docker-build-push.yml```
<img alt="githubaction" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/githubaction.png">


Expand All @@ -66,28 +63,28 @@ Remember both carefully because the secret is only displayed once and is require

See for more information [AWS Lambda] (https://docs.aws.amazon.com/de_de/lambda/latest/dg/getting-started.html)

1. Name the function alexa-actionable-notifications-function and select the Docker image from the ECR and click create function
2. Name the function alexa-actionable-notifications-function and select the Docker image from the ECR and click create function
<img alt="Select Container Lambda" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/select_container_lambda.png">

<img alt="Create Lambda" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/create_lambda.png">
<img alt="Overview Lambda" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/overview_lambda.png">


1. Click "Add Trigger" and copy your skill id from the previous step from the [Skill](https://developer.amazon.com/alexa/console/ask)
3. Click "Add Trigger" and copy your skill id from the previous step from the [Skill](https://developer.amazon.com/alexa/console/ask)

<img alt="Lambda Alexa Skill" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/lambda_alexa_skill.png">
<img alt="Trigger" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/trigger.png">


1. Now we have to log in to our Tailscale account and create an ephemeral key. Go to settings --> key
4. Now we have to log in to our Tailscale account and create an ephemeral key. Go to settings --> key
<img alt="Key" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/key.png">

<img alt="Key1" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/key1.png">
Please remember the key. You currently have to do this step every 3 months because the key can no longer be created.

1. An HA long-living token (10 years) must then be created that Lambda can access to your HA-Instance, which is only available into your VPN. Please remember the key.
5. An HA long-living token (10 years) must then be created that Lambda can access to your HA-Instance, which is only available into your VPN. Please remember the key.

1. Now the following ENV variables must be inserted into the function.
6. Now the following ENV variables must be inserted into the function.
<img alt="Key1" src="https://github.com/MelleD/alexa-actions/blob/main/docs/images/ha_env.png">


Expand All @@ -98,7 +95,7 @@ Please remember the key. You currently have to do this step every 3 months becau
| HA_URL | string | |**Important the TAILSCALE ip from HA** e.g http://{tailscale-ha-ip}:8123. Should be start with 100.xxx.xxx.xxx TAILSCALE_AUTHKEY the ephemeral key. Should be start with tskey-auth-xxxxx |


1. Save function to deploy the function new
7. Save function to deploy the function new

Now the Alexa skill can be tested and integrated into HA. These are the same steps like in the [wiki](https://github.com/keatontaylor/alexa-actions/wiki/Alexa-Talking-to-Home-Assistant-(The-Skill))

Expand All @@ -125,7 +122,7 @@ But you need to have a lot of traffic and updates. With testing and everything,

[release-badge]: https://img.shields.io/github/v/release/MelleD/alexa-actions?style=flat-square
[downloads-badge]: https://img.shields.io/github/downloads/MelleD/alexa-actions/total?style=flat-square
[build-badge]: https://img.shields.io/github/actions/workflow/status/MelleD/alexa-actions/build-linux.yml?branch=main&style=flat-square
[build-badge]: https://img.shields.io/github/actions/workflow/status/MelleD/alexa-actions/actions/workflows/build-linux.yml?branch=main&style=flat-square

<!-- References -->

Expand Down
11 changes: 2 additions & 9 deletions lambda/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@
import os

# Local Imports
from const import (
HA_URL,
HA_TOKEN,
SSL_VERIFY,
DEBUG,
AWS_DEFAULT_REGION,
ALL_PROXY
)
from const import HA_URL, HA_TOKEN, SSL_VERIFY, DEBUG, AWS_DEFAULT_REGION, ALL_PROXY


configuration = {
Expand All @@ -18,5 +11,5 @@
SSL_VERIFY: os.environ.get(SSL_VERIFY, default=False),
DEBUG: os.environ.get(DEBUG, default=False),
AWS_DEFAULT_REGION: os.environ.get(AWS_DEFAULT_REGION),
ALL_PROXY: os.environ.get(ALL_PROXY, default=None)
ALL_PROXY: os.environ.get(ALL_PROXY, default=None),
}
2 changes: 1 addition & 1 deletion lambda/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
SSL_VERIFY = "SSL_VERIFY"
DEBUG = "DEBUG"
AWS_DEFAULT_REGION = "AWS_DEFAULT_REGION"
ALL_PROXY = "ALL_PROXY"
ALL_PROXY = "ALL_PROXY"
14 changes: 4 additions & 10 deletions lambda/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
is_intent_name,
)

from ask_sdk_core.utils.request_util import (
get_intent_name,
get_slot,
get_slot_value,
get_account_linking_access_token
)
from ask_sdk_core.utils.request_util import get_intent_name, get_slot, get_slot_value, get_account_linking_access_token
from ask_sdk_model.session_ended_reason import SessionEndedReason
from ask_sdk_model.slu.entityresolution.status_code import StatusCode
from urllib3 import HTTPResponse
Expand All @@ -48,7 +43,7 @@
SSL_VERIFY,
DEBUG,
AWS_DEFAULT_REGION,
ALL_PROXY
ALL_PROXY,
)

logger = logging.getLogger()
Expand Down Expand Up @@ -125,7 +120,7 @@ def __init__(self, handler_input=None):
self.aws_region = configuration[AWS_DEFAULT_REGION]
self.proxy = configuration[ALL_PROXY]
logger.setLevel(logging.INFO)

if self.debug:
logger.setLevel(logging.DEBUG)

Expand All @@ -136,7 +131,7 @@ def __init__(self, handler_input=None):
# Define class vars
self.ha_state = None

if(self.proxy is None):
if self.proxy is None:
self.http = _init_http_pool(self.ssl_verify)
else:
logger.debug(f"Proxy is { self.proxy}")
Expand Down Expand Up @@ -684,7 +679,6 @@ def process(self, handler_input):
handler_input.attributes_manager.request_attributes["_"] = data



"""
The SkillBuilder object acts as the entry point for your skill, routing all request and response
payloads to the handlers above. Make sure any new handlers or interceptors you've
Expand Down

0 comments on commit 3dce727

Please sign in to comment.