tieum/haaska-tailscale

PSA: Account linking doesn't require external exposure

Opened this issue Β· 10 comments

Thanks for putting this repo together - exactly what I needed. This isn't an issue but possibly a useful bit of info for future users. I followed the Haaska wiki during setup which uses "Login with Amazon". Using this, during account linking you login via this service rather than direct to your HA installation thus never actually need to setup port-forwarding on your router. For the rest of the setup I was able to follow the OG Haaska to the letter other than using a container image for the Lambda. πŸ™

Thanks for your help, it works fine for me. I noticed the same thing as @walkert - it's not necessary to open your Home Assistant over the internet if you follow the Haaska wiki instead of the official Home Assistant documentation.

On the other hand, if you want to use Alexa for text-to-speech, you can install the "Alexa Media Player" add-on from HACS to do this. You will need to pair your "Alexa Media Player" add-on with your Amazon account and temporarily open your Home Assistant over the internet to connect your Alexa via OAuth. After that, you can definitively close your personal HA over the internet. I recommend following this tutorial to achieve that. Finally, you can send API calls to send commands to Alexa from HA πŸš€

@walkert do you have an idea: I get follow error in the lambda function

{
  "errorMessage": "SOCKSHTTPSConnectionPool(host='xxx, port=443): Max retries exceeded with url: /api/alexa/smart_home (Caused by NewConnectionError('<urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x7efcc1f01710>: Failed to establish a new connection: [Errno 97] Address family not supported by protocol',))",
  "errorType": "ConnectionError",
  "requestId": "896b86a1-16ba-4c71-879c-f044a714440d",
  "stackTrace": [
    "  File \"/var/task/haaska.py\", line 103, in event_handler\n    return ha.post('alexa/smart_home', event, wait=True)\n",
    "  File \"/var/task/haaska.py\", line 65, in post\n    timeout=(None, read_timeout))\n",
    "  File \"/var/task/requests/sessions.py\", line 577, in post\n    return self.request('POST', url, data=data, json=json, **kwargs)\n",
    "  File \"/var/task/requests/sessions.py\", line 529, in request\n    resp = self.send(prep, **send_kwargs)\n",
    "  File \"/var/task/requests/sessions.py\", line 645, in send\n    r = adapter.send(request, **kwargs)\n",
    "  File \"/var/task/requests/adapters.py\", line 519, in send\n    raise ConnectionError(e, request=request)\n"
  ]
}	

Iam using the https from tailnet directly
https://tailscale.com/kb/1153/enabling-https/

Hello @MelleD

The default port for Home Assistant is 8123, which is used for accessing the Home Assistant web interface. Port 443 is typically used for HTTPS traffic, but it is not the default port for Home Assistant.

What @vhuynen said. You don’t need to do anything to your tailnet to get this working. HTTPS isn’t a requirement here.

Thanks for the hint @walkert and @vhuynen. Not sure why I thought Alexa need a https connection :)

Short conclusion:

  1. With my internal ip it didn't work for me (HA_URL)
  2. With Tailscale https feature it didn't work (HA_URL)
  3. With my Tailscale ip address it worked http://{tailscaile-ip}:8123
  4. I builded a new image and upgraded the versions (pyhton,tailscale etc)

Question:
Is it normal that the lambda function is displayed offline in Tailscale at some point and I always have new machines in Tailscale?

In the test payload I see my new devices that I added in the config.yaml. However, in the Alexa app or at https://alexa.amazon.de/spa/index.html
no new devices are recognized. Anyone a tip?

Hello @MelleD,

If you can retrieve the device's details via the test console, I conclude that you can connect your Lambda Hasska with your Home Assistant.
Indeed, it is normal that the Lambda is displayed offline after a while. A Lambda function is serverless and instantiated on-demand.
Your Tailscale Key must be reusable, ephemeral, and pre-approved. The machine will be created on-the-fly and will be deleted after a while if ephemeral.

Have you activated your Hasska skills on the Alexa app?

Hey @vhuynen,

Your Tailscale Key must be reusable, ephemeral, and pre-approved. The machine will be created on-the-fly and will be deleted after a while if ephemeral.

My key is reusable and ephemeral, but cannot find a setting for pre-approved?

@vhuynen ok got it the lambda function have also be "ephemeral". Then it works smoothly :)
"This machine is ephemeral and will be automatically removed shortly after going offline."

wutr commented

If you use the "Login with Amazon" account linking, does the token the Alexa Skill gets assigned still expire after 30 days as per the last paragraph of this repo's readme?

That certainly hasn't been the case for me and it's ~8months since I set this up. If anything's expired I haven't logged out/in to find out.