Amazon Dash button hack, with power toggle (2 actions)

Hi

Using Dasher (https://github.com/maddox/dasher) and a series of automation scripts, i have managed to turn all my devices off if they are on and on if they are off, by triggering one automation script which is sent from the Dash button and using the HA API. I picked a trigger/state of a device i know will never fire as i only want to trigger this automation when i say so.

Here’s the automation and the json you need to upload to the dash button (follow the simple guide in link):

{"buttons":[
{
"name": "Turn on Script from Dash Button",
"address": "74:c2:46:xx:xx:xx", # mac address
"timeout": "60000",
"protocol": "udp",
"url": "https://duckdns.org:8123/api/services/automation/trigger",
"method": "POST",
"headers": {"x-ha-access": ""}, # password here
"json": true,
"body": {"entity_id": "automation.dash_button__all_off"}
}]} 


automation dash button off:
alias: dash off
initial_state: True
hide_entity: False
trigger:
platform: state
entity_id: media_player.kodi
to: 'stopped'
action:
- service: homeassistant.turn_off
  entity_id: light.large_l,light.small_l,light.stairs,light.kitchen,switch.testing_hyperion,media_player.sony_tv
- service: homeassistant.turn_on
  entity_id: switch.kodi_input_amp
automation dash button on:
alias: dash on
initial_state: True
hide_entity: False
trigger:
platform: state
entity_id: media_player.kodi
to: 'stopped'
action:
- service: homeassistant.turn_on
  entity_id: light.large_l,light.small_l,light.stairs,light.kitchen,switch.testing_hyperion,media_player.sony_tv
- service: homeassistant.turn_on
  entity_id: switch.television_input_amp
automation dash button:
alias: Dash button - all off
initial_state: True
hide_entity: False
trigger:
platform: state
entity_id: media_player.kodi
to: 'stopped'
action:
- service: automation.trigger
  data_template:
    entity_id: >-
      {% if is_state('light.large_l', 'on') %}
        automation.dash_off
      {% else %}
        automation.dash_on
      {% endif %}

Cant seem to get the yaml in the right format so heres an attachment:
automation.yaml (1.3 KB)

2 Likes

Very interesting.
I have one question: what is the delay you are getting between the push and the automation being executed?

It’s about 1second. Iv given the device a static ip which speeds it up. 4 seconds without,

Rich

Great, I’ll give it a try!

Hi, after receiving a dash button, I have managed to configure it with HA. I can toggle the specified group of lights based on the state of a single light following your example.

Giving a static ip, the fastest it gets detected is 4-5seconds.

Any special configuration I could try @Rich_Paul to achieve the 1second response time?

Regards,

Using hass.io and dasshio with a reserved IP for the button, I get 1 second or less response every time, doesn’t need anything special set up.

Have you got a decent router?

@Bobby_Nobble thanks for the advice. I guess it is related to router performance, currently I use the ISP router.
I’ll test moving my HA machine to a port in the router, just to discard the fact that the HA machine is in another network segment.

I personally haven’t changed anything to get it to run in a second other than giving it a static ip. My up is virgin and I have their super hub.

I have added a switch to start dasher from homeassistant but that’s just to get it to work once ha has rebooted.

I’d be tempted to use a trigger that is even less likely to never happen, for example the sun achieving an elevation that it just does not reach at your latitude. Or a temperature that would mean your hub has already melted!

Ha ha.

Could be anything, although since kodi has become whack ill stick with that.

Worth noting that I think this is now breaking homeassistant :

Sudo: hassbian-config: command not found