diff --git a/README.md b/README.md index 767eaa0..f480264 100644 --- a/README.md +++ b/README.md @@ -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 @@ -37,12 +34,12 @@ 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 ecr-private 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_ Zugriff Schlüssel @@ -50,10 +47,10 @@ See for more information [AWS Introduction credentials] (https://docs.aws.amazon 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 github secret -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``` githubaction @@ -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 Select Container Lambda Create Lambda Overview Lambda -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) Lambda Alexa Skill Trigger -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 Key Key1 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. Key1 @@ -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)) @@ -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 diff --git a/lambda/config.py b/lambda/config.py index 24646fa..39a80e3 100644 --- a/lambda/config.py +++ b/lambda/config.py @@ -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 = { @@ -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), } diff --git a/lambda/const.py b/lambda/const.py index d1a3531..682d363 100644 --- a/lambda/const.py +++ b/lambda/const.py @@ -22,4 +22,4 @@ SSL_VERIFY = "SSL_VERIFY" DEBUG = "DEBUG" AWS_DEFAULT_REGION = "AWS_DEFAULT_REGION" -ALL_PROXY = "ALL_PROXY" \ No newline at end of file +ALL_PROXY = "ALL_PROXY" diff --git a/lambda/lambda_function.py b/lambda/lambda_function.py index 6fd116a..57e6f14 100644 --- a/lambda/lambda_function.py +++ b/lambda/lambda_function.py @@ -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 @@ -48,7 +43,7 @@ SSL_VERIFY, DEBUG, AWS_DEFAULT_REGION, - ALL_PROXY + ALL_PROXY, ) logger = logging.getLogger() @@ -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) @@ -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}") @@ -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