Nekmo / amazon-dash

Hack your Amazon Dash to run what you want.
MIT License
828 stars 67 forks source link

One button that can toggle between actions #69

Open chofo1979 opened 6 years ago

chofo1979 commented 6 years ago

What is the purpose of your issue?

Feature request (request for a new functionality)

Hello! Is there a way to make something like this: https://github.com/ServError/dasher-toggle

My problem is that I'm using a pogoplug and it did not went well with node.js because of its ARM processor architecture. So I found yours and python is working just fine but it would be awesome to have the toggle functionality so you can toggle between states (on, 50% dim, off... for lights on a wink hub using ifttt for example)

Sadly I cannot code, I just kind of understand it.

If it is of any help.. I found this while browsing for the solution: https://raspberrypi.stackexchange.com/questions/85505/toggle-state-to-trigger-a-function-with-a-button-in-python-loops-on-and-off-an

Thanks for this program!

Nekmo commented 6 years ago

Hello,

It could be added as a new feature but with the current config it is a bit complicated. I am making a Amazon-dash 2.0 version with a new configuration. I could add this feature in the new release.

However, there are still many months left for Amazon-dash 2.0. I can try to help you by doing a bash script.

Regards.

chofo1979 commented 6 years ago

Hello, Thanks for the response. It would be great to have it on version 2.0 then. I can test if/when you want me to.

So you can do it with a script? Thanks for offering to help. Where do we start? I have never made a script before. Will read a bit about it and then come back so that you can help me.

Thanks again!

Nekmo commented 6 years ago

try this script:

#!/usr/bin/env bash

FILE=~/.dash_on

if [ -f $FILE ]; then
   echo "Action is ON"
   amazon-dash test-device 00:11:22:33:44:55 --config /etc/amazon-dash.yml
   rm $FILE
else
   echo "Action is OFF."
   amazon-dash test-device 00:11:22:33:44:66 --config /etc/amazon-dash.yml
   touch $FILE
fi

Save the file as /usr/local/bin/toggle.sh. After grant perms:

chmod +x /usr/local/bin/toggle.sh

And add this script to Amazon-dash config:

# amazon-dash.yml
# ---------------
settings:
  delay: 10
devices:
  0C:47:C9:98:4A:12:
    name: Hero
    user: nekmo
    cmd: /usr/local/bin/toggle.sh
  00:11:22:33:44:55:  # Fake mac
    name: Pompadour1
    ifttt: cdxxx-_gEJ3wdU04yyyzzz
    event: action_1
  00:11:22:33:44:66:  # Fake mac
    name: Pompadour2
    ifttt: cdxxx-_gEJ3wdU04yyyzzz
    event: action_1

Regards