Native Home Assistant support on Amazon-dash python project

@Nekmo when I run the test I get:

Traceback (most recent call last):
  File "/usr/local/bin/amazon-dash", line 6, in <module>
    catch(cli)()
  File "/usr/local/lib/python3.5/dist-packages/amazon_dash/exceptions.py", line 91, in wrap
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 676, in main
    _verify_python3_env()
  File "/usr/local/lib/python3.5/dist-packages/click/_unicodefun.py", line 118, in _verify_python3_env
    'for mitigation steps.' + extra)
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment.  Consult http://click.pocoo.org/python3/for mitigation steps.

This system supports the C.UTF-8 locale which is recommended.
You might be able to resolve your issue by exporting the
following environment variables:

    export LC_ALL=C.UTF-8
    export LANG=C.UTF-8

Click discovered that you exported a UTF-8 locale
but the locale system could not pick up from it because
it does not exist.  The exported locale is "en_US.UTF-8" but it
is not supported

Good news - I fixed that error by running:

export LC_ALL=C.UTF-8
export LANG=C.UTF-8

Bad news, it’s telling me my MAC address is not in my config file:

Welcome to Amazon-dash v1.1.1 using Python 3.5.3

[Error] Amazon Dash Exception (InvalidDevice):

Device 38:F7:3D:74:F2:D3 is not in config file.

I got this to work using this example as a starting point. Created an Event Trigger automation.

#automations.yaml
- id: ziplockDashButton
  alias: "DashTurn on light"
  trigger:
    platform: event
    event_type: toggle_kitchen_light
  action:
  - service: light.toggle
    entity_id: light.cree_connected_a19_60w_equivalent_xxxxxxx_10

Then the amazon-dash.yml looks like this.

settings:
  delay: 10
devices:
  50:F5:DA:XX:XX:XX:
    name: Fairy
    homeassistant: https://<my_url>:<my_port> 
    event: toggle_kitchen_light 
    access: <api_password

I used https for protocol, url was the name that matched my ssl cert, and the correct port.

Andy

1 Like

I’m going to start migrating to this and want to make sure I have it setup right. My test button is as follows in Dasshio

{
  "name": "Crawlspace Light Button",
  "address": "18:74:2e:d7:09:22",
  "domain": "light",
  "service": "toggle",
  "service_data": "{\"entity_id\": \"light.sengled_e11g13_0310615b_1\"}"
}

and my amazon-dash.yml for the same button looks like this.

18:74:2e:d7:09:22:
name: Crawlspace Light Button
url: ‘http://172.16.6.5:8123/api/services/light/toggle
method: post
content-type: application/json
headers: ‘{“x-ha-access”: “supersecret”}’
body: ‘{“entity_id”: “light.sengled_e11g13_0310615b_1”}’

Does the second one look right?

I’m using HASS events instead of RESTful URLs, so I can’t comment there, but the x-access-header shouldn’t be used anymore (at some point, it will go away). Instead, you should use a long-lived access token (generated in your HASS user configuration screen).

For instance, here’s one of mine:

devices:
  18:74:2E:FC:F0:AB:
    name: Amazon Basics Batteries
    homeassistant: http://hass:8123
    access_token: TOKEN
    event: AMAZON_DASH_PRESS
    data: '{"button_label": "Amazon Basics Batteries"}'

Thanks for the help.

     devices:
       18:74:2e:d7:09:22:
         name: Crawlspace Light Button
         url: 'http://172.16.6.5:8123/api/services/light/toggle'
         method: post
         content-type: application/json
         access_token: noway
         body: '{"entity_id": "light.sengled_e11g13_0310615b_1"}

Now to figure out these two

     {
       "name": "Boys Room Button",
       "address": "78:e1:03:69:15:39",
       "domain": "script",
       "service": "boys_room_ceiling",
       "service_data": "{\"button\": \"kids_button\"}"
     },
     {
       "name": "Master Button",
       "address": "00:fc:8b:12:78:a3",
       "domain": "script",
       "service": "boys_room_ceiling",
       "service_data": "{\"button\": \"master_button\"}"
     }

This might be a dumb question, but how is this better/different than DasshIO? Why would one switch from DasshIO to this?

This is for people who aren’t running Hass.io. Its aimed at more than just Home Assistant.

Hello everyone.
this is my first comment. I need your help. I’m stuck. I have raspberry with raspian + home assistant in a virtual environment. ([official guide(http://www.home-assistant.io/docs/installation/raspberry-pi/))
I followed the instruction to install the amazon-dash official guide but now I have some difficult to configure it.

# amazon-dash.yml
settings:
  delay: 10
devices:
  WE:XX:66:XX:XX:A5: 
    name: Dash button  
    homeassistant: http://XXX.XXX.X.XXX:8123  
    access_token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    event: toggle_switch.lampada_bagnetto_piano_interrato

And in home assistant in the automation.yaml

- alias: Premuto bottone dash
  trigger:
    - platform: event
      event_type: toggle_switch.lampada_bagnetto_piano_interrato
  action:
    - service: script.turn_on
      entity_id: script.dashbutton
    - service: switch.toggle
      entity_id: switch.lampada_bagnetto_piano_interrato

If i trigg manualy the automation in home assistant it works. But I’m not able to check if the event start from amazon-dash to home assistant ( When I press the dash button). Where I can check in home assistant if event arrive? ( in the “home-assistant.log” there are not information about events). Do you see some error anywhere in my code?

EDIT—
I used the command terminal:
amazon-dash debug and amazon-dash check-config (inside the folder of the file “amazon-dash.yml”. In my case was /etc ). I discover that there was a mistake formatting of the file “amazon-dash.yml” (my fault!) It’s a great tool! thanks Nekmo!