GithubHelp home page GithubHelp logo

nekmo / amazon-dash Goto Github PK

View Code? Open in Web Editor NEW
812.0 28.0 68.0 5.22 MB

Hack your Amazon Dash to run what you want.

License: MIT License

Python 97.55% Makefile 1.94% Dockerfile 0.51%
amazon python button home-automation home-assistant iot dash amazon-dash amazon-dash-button openhab

amazon-dash's Introduction

image

pip-rating badge

Latest PyPI version

Python versions

Code Climate

Test coverage

Github stars

DEVELOPMENT BRANCH: The current branch is a development version. Go to the stable release by clicking on the master branch.

Amazon-dash is still alive

Amazon has abandoned the Amazon-dash buttons, but this project wants to keep them alive. However, we are looking for alternatives. If you have suggestions you are welcome to open an incident. All suggestions are welcome. You can open an issue with your suggestions.

Python Amazon Dash

Hack your Amazon Dash to run what you want. Without welders. For the entire family.

This program written in Python runs in daemon mode waiting for someone in the same network to press a configured Amazon Dash button. It is not necessary to know programming to use this program. Amazon-Dash executes commands by command line, calls a url and more. This program works well on a Raspberry PI or on computers with few resources.

  1. Install Amazon Dash:
$ sudo pip3 install amazon-dash  # and after:
$ sudo python3 -m amazon_dash.install

Also available on AUR and FreeNAS. You can also use pip2 and python2 if your system only has Python2, but Python 3 is the recommended version. See other installation methods in the documentation.

Note: It may also be necessary to install tcpdump on your system (in Debian apt install tcpdump).

  1. Hack and configure Wi-Fi:

You must hack your button with the hack-device command if you have never used it. Then you must configure the Wifi connection. You can skip this step if you have already configured the Wi-Fi connection to the router.

  1. Avoid a connection to Amazon servers

Since 2020 your buttons can be bricked in an update from Amazon servers. To continue using your buttons you must configure your router to block Internet connections from the buttons. More info in the Amazon-dash documentation.

4. Use discovery mode to know the mac of your Dash (Run the program, and then press any button). You can skip this step if you already know the mac address:

$ sudo amazon-dash discovery
  1. Edit config file (/etc/amazon-dash.yml):
# amazon-dash.yml
# ---------------
settings:
  delay: 10
devices:
  0C:47:C9:98:4A:12: # Command example
    name: Hero
    user: nekmo
    cmd: spotify
  AC:63:BE:75:1B:6F: # SSH example
    name: Tassimo
    cmd: door --open
    ssh: 192.168.1.23:2222
  AC:63:BE:67:B2:F1: # Url Webhook example
    name: Kit Kat
    url: 'http://domain.com/path/to/webhook'
    method: post
    content-type: json
    body: '{"mac": "AC:63:BE:67:B2:F1", "action": "toggleLight"}'
    confirmation: send-tg
  40:B4:CD:67:A2:E1: # Home Assistant example
    name: Fairy
    homeassistant: hassio.local
    event: toggle_kitchen_light
  18:74:2E:87:01:F2: # OpenHAB example
    name: Doritos
    openhab: 192.168.1.140
    item: open_door
    state: "ON"
    confirmation: send-pb
  44:65:0D:75:A7:B2: # IFTTT example
    name: Pompadour
    ifttt: cdxxx-_gEJ3wdU04yyyzzz
    event: pompadour_button
    data: {"value1": "Pompadour button"}
confirmations:
  send-tg:
    service: telegram
    token: '402642618:QwGDgiKE3LqdkNAtBkq0UEeBoDdpZYw8b4h'
    to: 24291592
    is_default: false
  send-pb:
    service: pushbullet
    token: 'o.BbbPYjJizbPr2gSWgXGmqNTt6T9Rew51'
    is_default: false

UPGRADE from previous versions

The following execution methods are supported with your Amazon Dash button with this program:

image

image

image

System command .. image:: https://goo.gl/Cq4bYC OpenHAB

Call url .. image:: https://goo.gl/L7ng8k IFTTT

Homeassistant

Amazon-dash also allows you to send a confirmation after pressing a button. You will also receive a message in case of failure. Telegram and Pushbullet are supported.

For more information see the documentation of the configuration file.

  1. Run the daemon:

If you use a Systemd system (Debian 8+, Fedora 15+, Ubuntu 15.04+, Arch Linux 2012+, OpenSUSE 12.1+, and more) execute:

$ sudo systemctl start amazon-dash

To run Amazon-dash at startup:

$ sudo systemctl enable amazon-dash

To run Amazon-dash manually look at the documentation.

Docker

Using Amazon Dash within docker is easy! First, pull the Docker image:

$ docker pull nekmo/amazon-dash:latest

Then, create a container and run Amazon Dash itself:

$ docker run -it --network=host \
             -v </full/path/path/to/amazon-dash.yml>:/config/amazon-dash.yml \
             nekmo/amazon-dash:latest \
             amazon-dash run --ignore-perms --root-allowed \
                             --config /config/amazon-dash.yml

Join the community

Do you need ideas on how to use Amazon Dash? See what the community does with this project. Some examples:

See all the examples in the community.

amazon-dash's People

Contributors

bachya avatar fiws avatar florie1706 avatar gpotter2 avatar leres avatar luiseok avatar nekmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amazon-dash's Issues

TypeError: 'errors' is an invalid keyword argument for this function

  • amazon-dash version: la última
  • Python version: 2.7.13
  • Operating System: raspbian stretch

Description

Me da una serie de errores si intento ejecutar cualquier comando, son estos:
pi@HomeAssistant:~ $ amazon-dash --help
Traceback (most recent call last):
File "/usr/local/bin/amazon-dash", line 6, in
from amazon_dash.management import execute_from_command_line
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/management.py", line 11, in
from amazon_dash.listener import Listener, test_device
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/listener.py", line 8, in
from amazon_dash.scan import scan_devices
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/scan.py", line 6, in
from scapy.all import *
File "/usr/local/lib/python2.7/dist-packages/scapy/all.py", line 10, in
from .config import *
File "/usr/local/lib/python2.7/dist-packages/scapy/config.py", line 11, in
from .data import *
File "/usr/local/lib/python2.7/dist-packages/scapy/data.py", line 184, in
TCP_SERVICES,UDP_SERVICES=load_services("/etc/services")
File "/usr/local/lib/python2.7/dist-packages/scapy/data.py", line 109, in load_services
f=open(filename, errors='ignore')
TypeError: 'errors' is an invalid keyword argument for this function

What I Did

No sé qué hacer
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

Catch PermissionError on scapy

/home/nekmo/.virtualenvs/amazon-dash/bin/python /home/nekmo/Workspace/amazon-dash/scripts/amazon-dash --config amazon-dash.yml --debug run
Traceback (most recent call last):
  File "/home/nekmo/Workspace/amazon-dash/scripts/amazon-dash", line 8, in <module>
    execute_from_command_line(sys.argv)
  File "/home/nekmo/Workspace/amazon-dash/amazon_dash/management.py", line 103, in execute_from_command_line
    execute_args(args)
  File "/home/nekmo/Workspace/amazon-dash/amazon_dash/management.py", line 65, in execute_args
    Listener(args.config).run(root_allowed=args.root_allowed)
  File "/home/nekmo/Workspace/amazon-dash/amazon_dash/listener.py", line 97, in run
    scan(self.on_push, lambda d: d.src.lower() in self.devices)
  File "/home/nekmo/Workspace/amazon-dash/amazon_dash/scan.py", line 8, in scan
    sniff(prn=fn, store=0, filter="udp", lfilter=lfilter)
  File "/home/nekmo/.virtualenvs/amazon-dash/lib/python3.6/site-packages/scapy/sendrecv.py", line 572, in sniff
    s = L2socket(type=ETH_P_ALL, *arg, **karg)
  File "/home/nekmo/.virtualenvs/amazon-dash/lib/python3.6/site-packages/scapy/arch/linux.py", line 468, in __init__
    self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))
  File "/usr/lib64/python3.6/socket.py", line 144, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
PermissionError: [Errno 1] Operation not permitted

Process finished with exit code 1

Not working on Raspberry pi?

Sorry if this isn't the place for this but I can't find a forum. When trying to run on a fresh install of current Raspbian, which has Python 2.7 and 3.5.3 installed, I get to the point where I run the discovery and get:

pi@pi0w:~ $ sudo amazon-dash discovery
sudo: unable to resolve host pi0w
Traceback (most recent call last):
File "/usr/local/bin/amazon-dash", line 6, in
from amazon_dash.management import execute_from_command_line
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/management.py", line 9, in
from amazon_dash.exceptions import AmazonDashException
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/exceptions.py", line 12, in
class ConfigFileNotFoundError(AmazonDashException, FileNotFoundError):
NameError: name 'FileNotFoundError' is not defined

To try to force it to use Python3, I changed the first line of /usr/local/bin/amazon-dash to point to python3 instead of just python, as a test, and I get slightly different error:

pi@pi0w:~ $ sudo amazon-dash discovery
sudo: unable to resolve host pi0w
Traceback (most recent call last):
File "/usr/local/bin/amazon-dash", line 6, in
from amazon_dash.management import execute_from_command_line
ImportError: No module named 'amazon_dash'

I know I must be missing something really stupid, but dont know where to go from here. I can't be the only one trying to do this on RaspPi ZeroW, so hoping you may know.

Thanks for sharing your work.. I look forward to using this!!
-Steve

Logging

Any chance of logging either to standard output or a file? Sorry if I've missed it but there doesn't seem to be any reference to logs.

If I check sudo systemctl status dash.service it just says that it started OK, but doesn't report anything.

I'd like to see reports on button presses and commands sent.

I'm struggling to figure out why my light isn't toggling when I press a dash button, home assistant isn't showing any MQTT messages, so I believe amazon-dash must not be doing anything. Whether it's picking up the button press or not is unknown unfortunately.

Not able to run discovery

  • amazon-dash version: 1.0.2
  • Python version: 2.7.13
  • Operating System :Raspbian on Raspberry pi3 b+

Hi, I'm having problems and would really appreciate any help.
I'm trying to teach an old dog new tricks ; that old dog is me, a retired engineer(mechanical, unfortunately). I have some home automation set up on android using Tasker and RM Plugin etc and thought the next step would be to learn some coding so have recently bought and have set up a raspberry pi headlessly and accessing it by SSH and VNC. I thought I would ease into it by reproducing other peoples work so have been trying to re-purpose some dash buttons. After days of Googling , changing node.js versions, reinstalling npm, re-flashing etc, etc I still cannot get Mr Maddox's Dasher to work.
I then came accross your excellent work but I have failed again. I have started from a fresh install many times and run the apt-get update and upgrade commands. The pasted screen shots below show where I am currently at. It might be relevant to mention that on one occasion I tried following your instructions to delete previous attempts by command lines and the first instruction worked (pip uninstall from memory) but each of the other 3 rm commands returned that files could not be found (sorry I dont have actual screen shots of this).
I hope you can point me in the right direction please.

What I Did

pi@raspberrypi:~ $ sudo pip install amazon-dash
Collecting amazon-dash
Using cached https://www.piwheels.org/simple/amazon-dash/amazon_dash-1.0.2-py2.py3-none-any.whl
Requirement already satisfied: click-default-group in /usr/local/lib/python2.7/dist-packages (from amazon-dash)
Requirement already satisfied: click in /usr/local/lib/python2.7/dist-packages (from amazon-dash)
Requirement already satisfied: requests in /usr/local/lib/python2.7/dist-packages (from amazon-dash)
Requirement already satisfied: jsonschema in /usr/local/lib/python2.7/dist-packages (from amazon-dash)
Requirement already satisfied: scapy-python3 in /usr/local/lib/python2.7/dist-packages (from amazon-dash)
Requirement already satisfied: PyYAML>=3.0 in /usr/local/lib/python2.7/dist-packages (from amazon-dash)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/local/lib/python2.7/dist-packages (from requests->amazon-dash)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/local/lib/python2.7/dist-packages (from requests->amazon-dash)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python2.7/dist-packages (from requests->amazon-dash)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python2.7/dist-packages (from requests->amazon-dash)
Requirement already satisfied: functools32; python_version == "2.7" in /usr/local/lib/python2.7/dist-packages (from jsonschema->amazon-dash)
Installing collected packages: amazon-dash
Successfully installed amazon-dash-1.0.2

pi@raspberrypi:~ $ sudo python -m amazon_dash.install
Executing all install scripts for Amazon-Dash
[OK] config has been installed successfully
[OK] systemd service has been installed successfully
pi@raspberrypi:~ $ sudo amazon-dash discovery
Welcome to Amazon-dash v1.0.2 using Python 2.7.13
Traceback (most recent call last):
File "/usr/local/bin/amazon-dash", line 6, in
catch(cli)()
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/exceptions.py", line 91, in wrap
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/management.py", line 122, in discovery
from amazon_dash.discovery import discover
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/discovery.py", line 3, in
from amazon_dash.scan import scan_devices
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/scan.py", line 6, in
from scapy.all import *
File "/usr/local/lib/python2.7/dist-packages/scapy/all.py", line 10, in
from .config import *
File "/usr/local/lib/python2.7/dist-packages/scapy/config.py", line 11, in
from .data import *
File "/usr/local/lib/python2.7/dist-packages/scapy/data.py", line 184, in
TCP_SERVICES,UDP_SERVICES=load_services("/etc/services")
File "/usr/local/lib/python2.7/dist-packages/scapy/data.py", line 109, in load_services
f=open(filename, errors='ignore')
TypeError: 'errors' is an invalid keyword argument for this function
pi@raspberrypi:~ $

Dash Button not discovered / caught

  • amazon-dash version: 1.0.3
  • Python version: 3.4
  • Operating System: Linux raspberrypi 4.9.41+ #1023 Tue Aug 8 15:47:12 BST 2017 armv6l GNU/Linux

Description

When I run amazon-dash discovery, several devices (Echo, FireTV...), except the button, are shown. I grabbed the MAC from my routers interface and put it into /etc/amazon-dash.yaml. Sadly the Dash Button still isn't caught when amazon-dash is running, so nothing happens when the button is pressed.

What I Did

settings:
  # On seconds. Minimum time that must pass between pulsations.
  delay: 10
devices:
   ## Example of how to execute a url
 ac:63:be:b5:20:e6:
    name: ShitButton
    url: 'http://192.168.1.50/cm?user=admin&password=pass&cmnd=Power%20Toggle'  # Url to execute
    method: get  # HTTP method. By default GET

Are there new Dash Button models which use other communication methods or something?

Thanks,
T

Tox is not running Python 2.7 tests

py27 inst-nodeps: /home/nekmo/Workspace/amazon-dash/.tox/dist/amazon-dash-0.2.2.zip
py27 installed: amazon-dash==0.2.2,certifi==2017.11.5,chardet==3.0.4,codecov==2.0.10,coverage==4.4.2,funcsigs==1.0.2,functools32==3.2.3.post2,idna==2.6,jsonschema==2.6.0,mock==2.0.0,pbr==3.1.1,pyfakefs==3.3,PyYAML==3.12,requests==2.18.4,requests-mock==1.4.0,scapy==2.3.3,six==1.11.0,urllib3==1.22
py27 runtests: PYTHONHASHSEED='3018657133'
py27 runtests: commands[0] | python -m unittest

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OKEmpty test suite.

How to call the API of Homeassistant with curl

I want to make an API call to Homeassistant once the button is pressed.

On the command line I would run:

curl -X POST -H "x-ha-access: MyPassword" -H "Content-Type: application/json" -d '{"entity_id": "light.livingroom"}' https://www.mydomain.com:8123/api/services/light/toggle

How to do this from within this nice script?
I created a bash script file with the name test. If I put that in as command in the config file a get errors like:

2017-03-11 02:12:53,609 - amazon-dash - ERROR - 1 return code on "sudo -s --set-home -u myname /usr/bin/env bash -c test" command. Stderr: b''

How to fix this?

Request to url

Implement new way to execute commands: url. Instead of using the cmd parameter, use url:

devices:
  0C:47:C9:98:4A:12:
    url: http://my-domain/api/

Long example:

# amazon-dash.yml
# ---------------
settings:
  delay: 10
devices:
  0C:47:C9:98:4A:12:
    name: Execute API url
    url: http://my-domain/api/
    method: post
    content-type: json
    body: '{"key": "value"}'
Name Description Default
url Url to request
method HTTP method GET
content-type HTTP Content-Type Header* **
body Request payload

* Aliases available: form = application/x-www-form-urlencoded. json = application/json. plain = text/plain.
** Only available if Body is defined. If body is defined, default is form.

High CPU

  • amazon-dash version: V1.0.0
  • Python version: 3.5.3
  • Operating System: Raspbian

Description

I notice pretty high CPU usage on my pi due to amazon-dash at times.
Is that normal?
Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

Problem with "amazon-dash discovery" command on Raspbian Stretch

  • amazon-dash version:0.4.1
  • Python version:2.7
  • Operating System:Raspbian Stretch

Description

When I run "sudo amazon-dash discovery",
he gives me:
"pi@raspberrypi:~ $ sudo amazon-dash discovery
Traceback (most recent call last):
File "/usr/local/bin/amazon-dash", line 6, in
from amazon_dash.management import execute_from_command_line
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/management.py", line 11, in
from amazon_dash.listener import Listener, test_device
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/listener.py", line 8, in
from amazon_dash.scan import scan_devices
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/scan.py", line 6, in
from scapy.all import *
File "/usr/local/lib/python2.7/dist-packages/scapy/all.py", line 10, in
from .config import *
File "/usr/local/lib/python2.7/dist-packages/scapy/config.py", line 11, in
from .data import *
File "/usr/local/lib/python2.7/dist-packages/scapy/data.py", line 184, in
TCP_SERVICES,UDP_SERVICES=load_services("/etc/services")
File "/usr/local/lib/python2.7/dist-packages/scapy/data.py", line 109, in load_services
f=open(filename, errors='ignore')
TypeError: 'errors' is an invalid keyword argument for this function"
How can I solve?

Help instead raise FileNotFoundError when amazon-dash is not available

(amazon-dash) [nekmo@homura ~/Workspace/amazon-dash] (master)$ ./scripts/amazon-dash 
Traceback (most recent call last):
  File "./scripts/amazon-dash", line 8, in <module>
    execute_from_command_line(sys.argv)
  File "/home/nekmo/Workspace/amazon-dash/amazon_dash/management.py", line 95, in execute_from_command_line
    Listener(args.config).run(root_allowed=args.root_allowed)
  File "/home/nekmo/Workspace/amazon-dash/amazon_dash/listener.py", line 75, in __init__
    self.config = Config(config_path)
  File "/home/nekmo/Workspace/amazon-dash/amazon_dash/config.py", line 40, in __init__
    if (not os.getuid() and not only_root_write(file)) or oth_w_perm(file):
  File "/home/nekmo/Workspace/amazon-dash/amazon_dash/config.py", line 23, in oth_w_perm
    return bitperm(os.stat(file), 'w', 'oth')
FileNotFoundError: [Errno 2] No such file or directory: 'amazon-dash.yml'

Error on Scapy: TypeError: 'errors' is an invalid keyword argument for this function

  • amazon-dash version: 0.4.1
  • Python version: 2.7.13
  • Operating System: RPi 3 running Raspbian Stretch

Description

I followed the installation instructions and installed tcpdump as well. However, I keep getting the error below and the program will not run.

What I Did

pi@raspberrypi:~ $ amazon-dash --help
Traceback (most recent call last):
File "/usr/local/bin/amazon-dash", line 6, in
from amazon_dash.management import execute_from_command_line
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/management.py", line 11, in
from amazon_dash.listener import Listener, test_device
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/listener.py", line 8, in
from amazon_dash.scan import scan_devices
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/scan.py", line 6, in
from scapy.all import *
File "/usr/local/lib/python2.7/dist-packages/scapy/all.py", line 10, in
from .config import *
File "/usr/local/lib/python2.7/dist-packages/scapy/config.py", line 11, in
from .data import *
File "/usr/local/lib/python2.7/dist-packages/scapy/data.py", line 184, in
TCP_SERVICES,UDP_SERVICES=load_services("/etc/services")
File "/usr/local/lib/python2.7/dist-packages/scapy/data.py", line 109, in load_services
f=open(filename, errors='ignore')
TypeError: 'errors' is an invalid keyword argument for this function

Python2 unsupported

Traceback (most recent call last):
  File "/usr/local/bin/amazon-dash", line 8, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/amazon_dash/management.py", line 95, in execute_from_command_line
    Listener(args.config).run(root_allowed=args.root_allowed)
  File "/usr/local/lib/python2.7/dist-packages/amazon_dash/listener.py", line 75, in __init__
    self.config = Config(config_path)
  File "/usr/local/lib/python2.7/dist-packages/amazon_dash/config.py", line 39, in __init__
    super().__init__(**kwargs)
TypeError: super() takes at least 1 argument (0 given)

Button not being detected using Wi-Fi extender

Pressing my dash button doesn't seem to be noticed by amazon-dash. I have enabled debug logging and then run sudo systenctl status dash.service and there's nothing showing up. I get the amazon notification, so I know the button is working.

I've installed on a raspberry pi 3, which is also my network dns server and dhcp server, but not my gateway. Its connected via ethernet.

What further steps could I take to debug this issue?

Raspberry install Failed

  • amazon-dash version:0.4.1
  • Python version:3.5
  • Operating System:Raspbian Jessi Lite

Description

When I execute sudo python -m amazon_dash.install it fails with the text:
"/usr/bin/python: No module named amazon_dash"
"/usr/bin/python3.5: Error while finding module specification for 'amazon_dash.install' (ImportError: No module named 'amazon_dash')"
"/usr/bin/python3: Error while finding module specification for 'amazon_dash.install' (ImportError: No module named 'amazon_dash')"

What I Did

Reinstall and install with pip3 install amazon-dash
Tried which all variant of python --> "python" / "python3" / "python3.5"

Start on boot

Hi, what's the best way of making this start on boot?

I'm running it from a Raspberry Pi, and the only way I was able to make it successfully make it run as as root on boot was to add the following line to /etc/rc.local:

su pi -c 'cd /home/pi/Code/automate && sudo amazon-dash run < /dev/null &'

As you can see, this changes to the directory that contains the amazon-dash.yml file, then runs sudo amazon-dash run. I'm not sure what the rest of the line does, or if it's required, but this whole approach seems like overkill, and I can't help but feel it's wrong.

I guess I have two question in that case:

  • is there a way of running the script by passing in a path to the config file (rather than having to cd into the directory that contains the file)
  • is there a better way of running the script on boot, maybe via init.d or something like that?

Thank you.

Access password-protected URL

I'd like the script to GET a password-protected URL when the button is pressed. Is this supported in the script or do I have to run a wget with the user name and password in the command?

Thanks

  • amazon-dash version: 1.0.0
  • Python version:
  • Operating System: Ubuntu Linux 17.10

Error installing amazon-dash on dietpi distro

  • amazon-dash version: v1.0.2
  • Python version: 2.7.13
  • Operating System: dietpi

Description

Hi and thank you so much for amazon-dash. Great job!
I am a newbie with python so, I don't know which is the problem here when I try to install amazon-dash:

root@diet-hass:/etc# python -m amazon_dash.install
Executing all install scripts for Amazon-Dash
[Already installed] /etc/amazon-dash.yml already exists
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/install/main.py", line 3, in
catch(cli)()
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/install/init.py", line 35, in wrap
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/install/init.py", line 140, in all
has_service = has_service or (service().install() and
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/install/init.py", line 59, in install
self.is_installable()
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/install/init.py", line 95, in is_installable
if not get_pid('systemd') or not get_systemd_services_path():
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/install/init.py", line 21, in get_pid
return check_output(["pidof", name])
File "/usr/lib/python2.7/subprocess.py", line 219, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['pidof', 'systemd']' returned non-zero exit status 1

Any help will be appreciated
Adrian

Confirmations config

Confirmations section:

    confirmations:
      telegram-dash-bot:
        service: telegram
        token: 50164****:ABGDgiKEHFTeKnAtBkq0UEeBODdpZY*****
        is_default: false

On devices:

    devices:
      0C:47:C9:98:4A:12:
        name: Hero
        confirmation: telegram-dash-bot
        user: nekmo
        cmd: spotify

':' in url

  • amazon-dash version: v1.0.2
  • Python version: 2.7.3.
  • Operating System: Raspbian

I tried to call a url with a port number (http://x.x.x.x:port/restofurl).

it gives me
[Error] Amazon Dash Exception (InvalidConfig): The configuration file is invalid (/home/pi/amazon-dash.yml). Check the file and read the documentation. 'name', 'url' do not match any of the regexes: '^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$'
are there any other ways to use a certain port in a url?

running systemctl

amazon-dash version: v1.0.2
Python version: 2.7.3.
Operating System: Raspbian

$ sudo systemctl start amazon-dash

gives me

Failed to start amazon-dash.service: Unknown unit: amazon-dash.service

running it with sudo amazon-dash run works

i would appreciate any ideas where to start looking. i tried going my usual way with python scripts and install a crobtab, but i failed miserably.

SSH support

Execute command under ssh connection. For example:

00:11:22:33:44:55:
  cmd: command
  ssh: nekmo@host

Delay

What unit is the delay in? Seconds? Minutes?

I would guess at seconds, because the dash button seems to be active for just under that. Is there a minimum that we shouldn't go below? Does it take a certain amount of time for the button to drop off the network ready to be picked up again?

issue with config file

amazon_dash.exceptions.SecurityException: There should be no permissions for other users in the file "amazon-dash.yml". Only root must be able to write to file.

I get this even after setting chmod 700 to the file.

Error running a command

Hi there, thanks for creating amazon-dash!

Wanted to give it a try and encountered the below error when the button is pressed -

root@DietPi:~# amazon-dash --config=amazon-dash.yml run
Traceback (most recent call last):
File "/usr/local/bin/amazon-dash", line 8, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/management.py", line 103, in execute_from_command_line
execute_args(args)
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/management.py", line 65, in execute_args
Listener(args.config).run(root_allowed=args.root_allowed)
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/listener.py", line 72, in run
scan_devices(self.on_push, lambda d: d.src.lower() in self.devices)
File "/usr/local/lib/python2.7/dist-packages/amazon_dash/scan.py", line 12, in scan_devices
except PermissionError:
NameError: global name 'PermissionError' is not defined

image
rishav.sh.txt
amazon-dash.yml.txt

Home Assistant authorization

Is there a way to pass authorization to Home Assistant?

    name: Basics
    url: 'http://ha_ip:8123/api/services/switch/toggle'
    method: post
    headers: {"authorization": "ha_password"}
    content-type: json
    body: '{"entity_id": "light.hall"}'

Gave me 401 error

Troubleshooting my config on hassbian image

  • amazon-dash version: 1.0.1
  • Python version:3.5.3
  • Operating System: Hassbian 4.9.80-v7+ #1098 SMP Fri Mar 9 19:11:42 GMT 2018 armv7l GNU/Linux

Description

I try to get the buttons working for triggering lights, scripts and what ever for Home Assistant.
Made a simple toogle witch is also working on the command line. but not, when i press the buttons.

Funny thing is, yesterday eveining it worked one time, in a loop. Hadnt installed tcpdump (my own disco)
Now with tcpdump the discovery element dont show the button presses (Amazon device) but the 15 other connected devices.

Do i maybe have to set up a port forwarding in my router??

What I Did

pi@hassbian:~ $ sudo systemctl status amazon-dash.service
● amazon-dash.service - Amazon Dash service
   Loaded: loaded (/lib/systemd/system/amazon-dash.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-04-13 10:21:10 CEST; 44s ago
 Main PID: 331 (amazon-dash)
   CGroup: /system.slice/amazon-dash.service
           └─331 /usr/bin/python3 /usr/local/bin/amazon-dash run --config /etc/amazon-dash.yml

Apr 13 10:21:10 hassbian systemd[1]: Started Amazon Dash service.
Apr 13 10:21:12 hassbian env[331]: Welcome to Amazon-dash v1.0.1 using Python 3.5.3
Apr 13 10:21:12 hassbian env[331]: Listening for events. Amazon-dash will execute the events associated with the registered buttons.
pi@hassbian:~ $ ps ax|grep dash
  331 ?        Ss     0:10 /usr/bin/python3 /usr/local/bin/amazon-dash run --config /etc/amazon-dash.yml
  759 pts/0    S+     0:00 grep --color=auto dash
pi@hassbian:~ $ sudo journalctl -r -u amazon-dash
-- Logs begin at Thu 2016-11-03 18:16:42 CET, end at Fri 2018-04-13 10:24:40 CEST. --
Apr 13 10:21:12 hassbian env[331]: Listening for events. Amazon-dash will execute the events associated with the registered buttons.
Apr 13 10:21:12 hassbian env[331]: Welcome to Amazon-dash v1.0.1 using Python 3.5.3
Apr 13 10:21:10 hassbian systemd[1]: Started Amazon Dash service.
pi@hassbian:~ $ sudo amazon-dash test-device 0c:47:c9:fc:7a:cb --config /etc/amazon-dash.yml
Welcome to Amazon-dash v1.0.1 using Python 3.5.3
pi@hassbian:~ $ pip freeze
amazon-dash==1.0.1
certifi==2018.1.18
chardet==3.0.4
click==6.7
click-default-group==1.2
cryptography==1.7.1
dnspython==1.15.0
enum34==1.1.6
functools32==3.2.3.post2
idna==2.6
ipaddress==1.0.17
jsonschema==2.6.0
keyring==10.1
keyrings.alt==1.3
pyasn1==0.1.9
pycrypto==2.6.1
pygobject==3.22.0
pyxdg==0.25
PyYAML==3.12
requests==2.18.4
RPi.GPIO==0.6.3
scapy-python3==0.23
SecretStorage==2.3.1
six==1.10.0
urllib3==1.22


Dash service installed via your installer, looks good
after trying around 4hrs im at the end of my ideas..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.