Announcement

Collapse
No announcement yet.

How To Integrate Amazon Dash Buttons

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How To Integrate Amazon Dash Buttons

    Note: This guide is only useful for people that are comfortable with python, yaml, and potentially docker.

    I picked up a 10 pack of these on eBay for about $15 with the intent of using them for simple things around my house. I knew they had a delay, but that didn't really matter for my uses (The delay is anywhere from 1-3 seconds). I originally was using the windows based tool (http://amazondashtool.com I recommend using this tool if you don't want to mess with any of this, but it's Windows only) to control these with HomeSeer, but with a little finagling, I find this solution to be a little better. I've moved about 95% of my home server and automation stuff to dockers, so this is part of that journey instead of using Windows. Eventually I'm hoping to get HS3 working nicely in a docker too.

    This assumes you already know how to setup/pair the buttons and get their mac address, and know how to setup the amazon-dash tool (Instructions here: https://github.com/Nekmo/amazon-dash). I'm currently running it in a docker, and it works great. To be clear, amazon-dash does all the heavy lifting.

    The two biggest hurdles I had is I wanted to use the buttons to toggle items. I have them on my nightstand for toggling a lamp on/off, and turn the tv on/off. Most people use these buttons to complete a single on or off event. This technique uses a amazon-dash to trigger a bash script which will allow you to toggle the device.

    First things first, my amazon-dash.yml file (I've truncated it and changed the MAC addresses):

    Code:
    # amazon-dash.yml
    # ---------------
    settings:
      delay: 5
    devices:
      18:74:2E:DA:XX:XX:
        name: Shelby Lamp
        user: root
        cmd: /config/toggle.sh 192.168.1.185 232
      88:71:E5:75:XX:XX:
        name: Scott Lamp
        user: root
        cmd: /config/toggle.sh 192.168.1.185 80
      B4:7C:9C:12:XX:XX:
        name: Shelby TV
        user: root
        cmd: /config/toggle.sh 192.168.1.185 135
    And the bash script (I named it toggle.sh):

    Code:
    #!/bin/bash
    
    STATUS=$(curl -s 'http://'"$1"'/JSON?request=getstatus&ref='"$2" | jq --raw-output '.Devices | to_entries[] | .value.status')
    if [ "$STATUS" = 'Off' ]; then
        curl -s 'http://'"$1"'/JSON?request=controldevicebylabel&ref='"$2"'&label=On'
    elif [ "$STATUS" = 'On' ]; then
        curl -s 'http://'"$1"'/JSON?request=controldevicebylabel&ref='"$2"'&label=Off'
    fi
    For the bash script, the first argument is the IP of your HomeSeer server, the second is the deviceID of the device you're toggling. The bash script needs to be on the same machine as the amazon-dash program. In this case I have it in a docker in the /config folder. The nice thing about executing a bash script instead of just doing a single call to turn on the device is that I can do several things including checking the states of various objects.

    I chose to control via label instead of value because I have some lights that use 1 as on and some that use 100 as on. Using the label ensures they all turn on/off with no modification.

    If you're using the built docker file provided, you'll need to get into the container and install bash, jq, and curl (apk add --no-cache curl jq bash).

    You can also get similar behavior instead of using the bash script and just changing the value of an event in HomeSeer via a JSON call.

    I also understand there isn't enough information here for someone to do something start to finish, but it gives people some of the tools I found useful. Having said all that, this is a nice, cheap solution to having wireless, concealable push buttons that work with HomeSeer.

  • #2
    Nice write-up. Thanks for sharing it. Something of note relating to this, and it may be old news, but I saw it announced yesterday that amazon stopped selling the dash buttons. May want to grab any you can get your hands on.
    -Wade

    Comment

    Working...
    X