Native Home Assistant support on Amazon-dash python project

Hello,

A few years ago I started a Python project to support the Amazon Dash buttons and now I’m starting with Home Assistant.

I liked Home Assistant a lot and I added native support in my project that I hope may also be useful to the community.

The project is tested (coverage 96%) and it is well documented: http://docs.nekmo.org/amazon-dash/

The installation is very easy, it can be done with pip and the configuration is in yaml.

  40:B4:CD:67:A2:E1:
    name: Fairy
    homeassistant: hassio.local
    event: toggle_kitchen_light

Thanks to all :slight_smile:

2 Likes

I get the error “/usr/bin/python: No module named amazon_dash” on the second installation command.

Hi, that means Amazon-dash has not been installed correctly. Maybe it’s not the same version as Pip.

What error does it return to you by executing pip install amazon-dash? Also check Pip Python version.

Pip version:

[root@haruka ~]# pip --version
pip 9.0.1 from /usr/lib/python3.6/site-packages (python 3.6)

Python version:

[root@haruka ~]# python --version
Python 3.6.4

To upgrade:

[root@haruka ~]# python install -U amazon-dash

I get the following

-bash: pip: command not found

I then used the pip3 command to install, do I need to install an older version?

Okay, so I’ve got it installed. However I’m a little confused at the amazon-dash.ym config, would you be able to give me an example for turning on a script in hassbian, not hassio please?

If you use pip3 to install the program you also need python3 to run it. :slight_smile:

This is an example of the execution of a system script:

  0C:47:C9:98:4A:12:
      name: Hero
      user: nekmo
      cmd: /path/to/script.sh

More info in the documentation: http://docs.nekmo.org/amazon-dash/config_file.html

If you have any other questions, tell me ^^

I have released a new version of this project (Release 1.0.0!).

To upgrade:

$ sudo pip install -U amazon-dash

Regards!

I can not figure this out for the life of me.

# amazon-dash.yml
# ---------------
settings:
  # On seconds. Minimum time that must pass between pulsations.
  delay: 2
devices:
  XX:XX:XX:XX:XX:XX:
    name: Repurpose
    homeassistant: 127.0.0.1
    event: light.turn_on
    data: { "entity_id": "light.daddys_office" }

but it does not work at all. Nothing I’ve done has been able to get it to work. The documentation is a bit weird, or else I’m just being dumb. what am I doing wrong here?

check-config says my yaml is fine.

MTA: Running test-device just gives me a 403. Seems I can’t run this locally from the command line because I’m not logged in from the device running HA? Anyway around this?

MAT (again): I’ve managed to get this running via URL call. Thanks for the work. Awesome little project. Now I just need to put it to good use.

Hi @forsquirel,
did you ever figure out how to use the right entries according to the example?

# amazon-dash.yml
# ---------------
settings:
  delay: 10
devices:
  40:B4:CD:67:A2:E1:
    name: Fairy
    homeassistant: hassio.local
    event: toggle_kitchen_light

Or can you just paste your an example of your URL call in here?

here’s an example of one of mine

  xx:yy:zz:aa:bb:cc:
    name: Wilson
    url: 'http://127.0.0.1:8123/api/services/cover/open_cover?api_password=password'
    method: post
    content-type: application/json
    body: '{ "entity_id": "cover.garage_door" }'

and this will open the garage door via the cover service.

Thanks for the quick response - here is what I’m using but it doesn’t trigger anything:

  FC:A6:67:11:22:33:  #MAC ADDRESS OF BUTTON
    name: TestDash
    url: 'http://192.168.7.14:8123/api/services/switch/turn_off'
    method: post
    content-type: application/json
    body: '{ "entity_id": "switch.etekcity_315_4" }'

It works fine when I set it up on my mobile phone via the ‘HTTP Shortcuts’ app - I baffled and :confused:

I can’t see a difference, but I’m also not sure if the event is fully triggered through the amazon-dash app - would you know of a way t check, if it’s even sent to my HAss instance?

you’re leaving out

?api_password=your-password

Amazon-dash uses events to trigger your Home Assistant Automations. Just use an event name in amazon-dash and create an automation in Homeassistant for your event.

If your Home Assistant installation requires a password, you can use the access parameter:

http://docs.nekmo.org/amazon-dash/config_file.html#homeassistant-event

Regards

Thanks again, @forsquirel!

I don’t use an API pasword.
The issue seems to be with my switch ‘etekcity_315_4’ - I tried another one and it now works fine.

Thanks @Nekmo - it seems to be working fine now, great little piece of software btw! :+1:

Sometimes, when all the documentation doesn’t help because I don’t understand all the details, I’m best off with a real-life example that I can modify according to what I want to achieve.

Hi @Nekmo! Thanks for the great project. I’m linking up my first dash button but can’t quite seem to get it to work.

I’ve got amazon-dash installed and running. I’m running hassbian for my home assistant install.

I added this to amazon-dash.yml after pulling the MAC address of my dash button and confirming it’s on the network:

devices:
  38:F7:3D:74:F2:D3:
    name: Patio_lights
    homeassistant: hassbian.local:8123  # Address to the hass server
    event: patio_lights_switch  # Event name to send

I have a wemo plug (switch in HASS) I’m trying to control with the dash button (patio string lights on/off). I set an automation with the custom event name to try and fire from the the button but nothing happens when I press it. Here is my automation code:

- id: patio_lights
  alias: Toggle Patio Lights
  trigger:
    platform: event
    event_type: patio_lights_switch
  action:
    service: switch.toggle
    entity_id: switch.patio_lights

Any thoughts on what I’m doing wrong? Appreciate the help!

This is what I’m using in the amazon-dash.yml file:

  AA:BB:CC:11:22:33:  #MAC ADDRESS OF BUTTON
    name: Check Home Security Status
    url: 'http://192.168.7.14:8123/api/services/input_boolean/turn_on'
    method: post
    content-type: application/json
    body: '{ "entity_id": "input_boolean.guest_mode" }'

And here is the trigger part of the automation that goes with it:

- alias: Security State Check
  trigger:
    - platform: state
      entity_id: input_boolean.guest_mode
      from: 'off'
      to: 'on'
  action:  

@Angelus Can you use test-device to test the execution? You can also look at the Home Assistant logs to check if Home Assistant receives your event.

sudo amazon-dash test-device 38:F7:3D:74:F2:D3 --config /etc/amazon-dash.yml

your amazon-dash configuration seems to be correct. Do you receive any errors in the execution?

Nope - my setup is working fine as is.
This was just meant as an example for @Angelus