Capture Amazon Dash button press

I’m waiting for my dash buttons to ship- when they get here I want to investigate potential ways of raising an event in HA when a button is pushed.
Some people have used the scapy library to listed of arp packets that the buttons emit. It looks like that may require root access though, so likely won’t be a native component, but maybe an external service that calls into HA to raise the event.

Check out this project. I am using it and it works very reliably. It takes the dash button push and turns it into an MQTT event which HASS can then act on.

3 Likes

Ahh- excellent! That’ll work- thanks!

Dumb question, but does this library override the call out to Amazon, or does it just capture that the call was made?

As far as I know, all it does it register that the button has connected to the network, and perform an action based on the MAC address. So once the button has been set up through Amazon and connected to your WiFi, you need to make sure that it is disconnected from your account otherwise you will be purchasing stuff every time you hit it.

If I recall, you get to the penultimate step configuring the Dash with Amazon then just quit the process. Then you never need to worry about the Dash again and just use it. Btw I think you are limited to ~1000 pushes so don’t go too crazy :grin:

mqtt-dasher looks cool, but has anyone found a way to detect button pushes without installing an external library?

Here is a project I am using. https://github.com/maddox/dasher
The issue with trying to do it via homeassistant is that HASS would have to be always listening on the network for the device press.

here is a link to where this was discussed. https://github.com/home-assistant/home-assistant/issues/484

1 Like

You only get 1000 presses before you have to crack open the button and replace the AA battery inside. Then it’s good to go again :slight_smile: If you take an x-acto knife and carefully cut along the plastic weld line you can put a few daubs of superglue on the case and put it back together and it’ll work fine. It’s sonic welded so there’s no way around this but this way does minimal damage to the switch itself.

2 Likes

I documented setting up mqtt-dasher as a service without having to run it as root (for Debian/Ubuntu + systemd distros):
https://www.markferry.net/HomeAutomation.MqttDasherService

If the button doesn’t communicate with Amazon (or at least something believably masquerading as amazon) it stays on for like 3-4 times as long as if it had connected.

is it very reliable, I amean from 1 to 10 how much?

95/100 I would say.
Maybe depends on your networking and what software you are using to listen to the arp requests from buttons

I used it with bruh automation video, and did not like the lag of ifttt. I guess with mqtt is faster?

Can you please tell me which instructions you followed, I am stuck

I’m using dasher: https://github.com/maddox/dasher
Since I am using docker containers, I run dasher in a container using this: https://github.com/clemenstyp/dasher-docker

Dasher calls the HA API.
E.g this is from the readme config:

 {
    "name": "Party Time",
    "address": "d8:02:dc:98:63:49",
    "url": "http://192.168.1.55:8123/api/services/scene/turn_on",
    "method": "POST",
    "headers": {"authorization": "your_password"},
    "json": true,
    "body": {"entity_id": "scene.party_time"}
  },

This is my dasher config:

{"buttons":[
  {
    "name": "Lounge Lights",
    "address": "mac address of button 1",
    "interface": "ens160",
    "url": "http://ubuntudocker:8123/api/services/light/toggle",
    "method": "POST",
    "headers": {"x-ha-access": "mypassword"},
    "json": true,
    "body": {"entity_id": "light.living_room"}
  },
  {
    "name": "Downstairs Lights",
    "address": "mac address of button 2",
    "interface": "ens160",
    "url": "http://ubuntudocker:8123/api/services/light/turn_off",
    "method": "POST",
    "headers": {"x-ha-access": "mypassword"},
    "json": true,
    "body": {"entity_id": "group.downstairs_switches"}
  },
  {
    "name": "Downstairs Switches",
    "address": "mac address of button 3",
    "interface": "ens160",
    "url": "http://ubuntudocker:8123/api/services/switch/turn_off",
    "method": "POST",
    "headers": {"x-ha-access": "mypassword"},
    "json": true,
    "body": {"entity_id": "group.downstairs_switches"}
  }
]}

Whilst I have left the dash buttons I configured in place, I am using xiaomi buttons elusively going forward due to:

  1. they respond immediately
  2. they are natively supported in HA (no need to configure API calls)
  3. they have multiple events (click, double click etc)
2 Likes

yeah, and they do not cost much more

I just use device_tracker / nmap to see when the mac address appears. Has been working great so far, just be sure your scan_interval is low enough (4 seconds should do it). I set consider_home to 30 seconds and added a wrapper template sensor to change the home/not_home to on/off.

2 Likes

It gets better - if you configure your router to block outbound traffic from the Dash (very easy to do on dd-wrt), you avoid pinging Amazon altogether AND your Dash stays on longer since it doesn’t get a responding confirmation. I’m at 100% reliability with a 8 second scan interval. Sure, I’ll probably now have to replace the AAA Dash battery after 2 years instead of 4, but that’s a small price to pay for a reliable smart button…I’m about to pickup 12 of these buttons for $20.

Here is a $3 smart doorbell:

Find your Dash in Device Tracker:

amazon_dash_1:
  mac: XX:XX:XX:XX:XX:XX
  name: "Amazon Dash 1"
  track: True
  vendor: Amazon Technologies Inc.
  consider_home: 00:00:10

Clean up the sensor formatting:

binary_sensor:
  - platform: template
    sensors:
      doorbell:
        friendly_name: "Doorbell"
        value_template: "{{ is_state('device_tracker.amazon_dash_1', 'home') }}"
        entity_id: device_tracker.amazon_dash_1

Automate a notification when pressed…

automation:
  - alias: Notify Doorbell Ring
    trigger:
      platform: state
      entity_id: binary_sensor.doorbell
      to: 'on'
    action:
      service: notify.all
      data:
        message: "Doorbell - someone at front door!"
        data:
          push:
            badge: 5
            category: "DOORLOCK" # This is configured with 2 options sent to IOS: unlock door or ignore
ios:
  push:
    categories:
      - name: DoorLock
        identifier: 'DOORLOCK'
        actions:
          - identifier: 'UNLOCK'
            title: 'Unlock Door'
            activationMode: 'background'
            authenticationRequired: yes #-require iphone password to unlock door
          - identifier: 'IGNORE'
            title: 'Ignore'
            activationMode: 'background'
            authenticationRequired: no

And if I press unlock when I get the notification…

- alias: Unlock Door from Doorbell Notification
  hide_entity: True
  trigger:
    platform: event
    event_type: ios.notification_action_fired
    event_data:
      actionName: UNLOCK
  action:
    - service: lock.unlock
      entity_id: lock.front_door_lock

Now to find a cheap way to capture an image of the person at the door…

6 Likes

Hi, are you able to specify which Xiaomi button you use?

I’d really like to do this myself.

Thanks in advance.

Hi,

I’m using these:
http://www.gearbest.com/smart-light-bulb/pp_257679.html

You also need to have a Xiaomi gateway like this:
http://www.gearbest.com/living-appliances/pp_344667.html

There is a new version of the switch just released, too:
http://www.gearbest.com/access-control/pp_626695.html

However the gateway does not yet support it. I assume support will come in the near future since the switch is available to buy.

For (much) more info take a look at the xiaomi thread - Xiaomi Gateway Integration