Nekmo / amazon-dash

Hack your Amazon Dash to run what you want.
MIT License
828 stars 67 forks source link

Https connection with Home Assistant #135

Closed browetd closed 5 years ago

browetd commented 5 years ago

Put an x into all the boxes [ ] relevant to your issue (like this: [x])

What is the purpose of your issue?

amazon-dash -- 1.3.2 python --3.5.3 pip --9.0.1 easy_install --setuptools 33.1.1



- [x] The `pip install` or `setup install` command has been completed without errors
- [x] The `python -m amazon_dash.install` command has been completed without errors
- [x] The `amazon-dash discovery` command works without errors
- [x] I have created/edited the configuration file
- [x] *Amazon-dash service* or `amazon-dash --debug run` works 

#### Description

I am using the amazon-dash with Home Assistant 0.89.1... With previous version of HA, I was using the "trusted network" feature to get the event from amazon-dash to HA (I am using a forced https connection on the Raspberry Pi).  With the last version of HA, that feature seems to be more stringent and the connection does not work anymore.   The "Legacy API password" method will be retired soon as well...

Here is my amazon-dash.yml
"settings:
  delay: 20
devices:
  XX:XX:XX:YY:YY:YY   #mac address of my device
    name: Bouton_Soir
    homeassistant: https://myweb.vvvvvvv.jjjjjjj:8123    # Address to the hass server
    event: activate_bouton_soir    # Event name to send"

With that config file,  I am receiving the error message in HA: "Login attempt or request with invalid authentication from xxx.xxx.xxx.xxx".   xxx.xxx.xxx.xxx is the IP address of my Internet IP...

I tried to change the access of the hass server by creating a "long term" token in HA, so I changed my configuration as followed:
"     homeassistant: https://myweb.vvvvvvv.jjjjjjj:8123 -H 'Authorization: abdcfrt cdfgytfg'    # Address to the hass server"

but that change crashed amazon-dash process 

Any idea how I should configure amazon-dash.yml to make it work with https ?

Thanks
Nekmo commented 5 years ago

You need to add authentication in your amazon-dash config to use the Home Assistant API.

browetd commented 5 years ago

Thanks... I was way too complicated... :-) I just had to add "access_token: mytoken" ("mytoken" is a long-lived token generated in HA) and it is working fine.