Amazon dash button: Things won't come online, INITIALIZING

@kociubin Thanks a lot for your detailed instructions.
Today I got the chance to test it.

It works great!

Typo: you missed an " at the end of line: curl -X POST …

Remark: for diagnostics you can run at the command line:
sudo amazon-dash
It shows you possible errors in the config file.

Hello everyone! I am the developer of the Amazon-dash project. I have added native support for OpenHAB. I hope it can be useful!

# amazon-dash.yml
# ---------------
settings:
  delay: 10
devices:
  18:74:2E:87:01:F2:
    name: Doritos
    openhab: 192.168.1.140
    item: open_door
    state: ON

Docs:
http://docs.nekmo.org/amazon-dash/config_file.html#openhab-event

I have not been able to personally test it but I have used the @kociubin code (thank you!) and I think it should work. If you can prove it, I would appreciate it.

To use native support for OpenHAB it is necessary to update to version 1.0.0

1 Like

@Nekmo: Thanks for including openhab support.
I’ll test it as soon as possible.
It makes the integration smarter for me.

I have installed the way of @Jens_Pirnay, now i want to change to the way of @Nekmo.

Can i simply remove all the installed files/programms/modules with apt-get remove “name”? All what was explained in the instruction, only with “remove” instead of install?

Or should i keep all the modules/files and only install the new application?

I did the complete fresh installation according to @Nekmo and @kociubin

But I have not tested the new OpenHab support which seems easier/smarter.
https://github.com/Nekmo/amazon-dash

I think yes.

@Nekmo I tried your latest release with openhab support. Unfortunately, it’s not working for me. Two issues:

  1. I get the following error after I press the button (I have “state: ON” in configuration file) :
Listening for events. Amazon-dash will execute the events associated with the registered buttons.
2018-03-14 22:04:32,259 - amazon-dash - DEBUG   - dash_On device executed (mac 74:75:48:e0:8e:dd)
Traceback (most recent call last):
  File "/usr/local/bin/amazon-dash", line 6, in <module>
    catch(cli)()
  File "/usr/local/lib/python3.5/dist-packages/amazon_dash/exceptions.py", line 91, in wrap
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/amazon_dash/management.py", line 100, in run
    Listener(config).run(root_allowed=root_allowed)
  File "/usr/local/lib/python3.5/dist-packages/amazon_dash/listener.py", line 154, in run
    scan_devices(self.on_push, lambda d: d.src.lower() in self.devices)
  File "/usr/local/lib/python3.5/dist-packages/amazon_dash/scan.py", line 24, in scan_devices
    sniff(prn=fn, store=0, filter="udp", lfilter=lfilter)
  File "/usr/local/lib/python3.5/dist-packages/scapy/sendrecv.py", line 603, in sniff
    r = prn(p)
  File "/usr/local/lib/python3.5/dist-packages/amazon_dash/listener.py", line 135, in on_push
    self.execute(device)
  File "/usr/local/lib/python3.5/dist-packages/amazon_dash/listener.py", line 145, in execute
    device.execute(root_allowed=self.root_allowed)
  File "/usr/local/lib/python3.5/dist-packages/amazon_dash/listener.py", line 82, in execute
    result = self.execute_instance.execute(root_allowed)
  File "/usr/local/lib/python3.5/dist-packages/amazon_dash/execute.py", line 180, in execute
    resp = request(self.data.get('method', 'get').lower(), self.data['url'], **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 460, in send
    for i in request.body:
TypeError: 'bool' object is not iterable



"

  1. If I try “state: TOGGLE” I get a different output. Are you sure TOGGLE is supported?
Welcome to Amazon-dash v1.0.0 using Python 3.5.2
Listening for events. Amazon-dash will execute the events associated with the registered buttons.
2018-03-14 22:06:22,976 - amazon-dash - DEBUG   - dash_On device executed (mac 74:75:48:e0:8e:dd)
[Error] Amazon Dash Exception (ExecuteError):
"http://192.168.1.15:8080/rest/items/FamilyRmTVviewingScene" return code 400.

1 Like

Hello, can you try please to change ON on the config file to “ON” (between quotes)? Thanks for your time :slight_smile:

I’m not 100% sure that TOGGLE works. If it does not exist, I will have to eliminate that option until I find a solution. Thank you again

Hi Nekmo,
I had the same Exception ("‘bool’ object is not iterable". Putting ON between quotes solved the problem. Now the buttons work like a charm in openhab. Thanks a lot !

My config in /etc/amazon-dash.yml now looks like
[…]
fd:a8:67:3a:a1:8e:
name: MyButton1
openhab: 192.168.2.100
item: DASH1
state: “ON”

In openhab’s item file “default.items” it looks like

Switch DASH1 “DASH-1-MyFirstDash”

And the corresponding rule in “default.rules”

rule “Rule for Dash-Button 1”
when
Item DASH1 received update
then
[…]

And for the ones using OpenHabian 1.4 there seems to be a configuration error (?) in the python config. Just in case you get the following error

[07:09:38] openhabian@openHABianPi:~$ sudo amazon-dash run
Welcome to Amazon-dash v1.0.0 using Python 2.7.13
Listening for events. Amazon-dash will execute the events associated with the registered buttons.
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 99, in run_
_ from amazon_dash.listener import Listener_
_ File “/usr/local/lib/python2.7/dist-packages/amazon_dash/listener.py”, line 9, 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

You probably have the wrong scapy version. Please check with

pip freeze

The output could look like this (note “scapy-python3” although I am using python 2.7):

amazon-dash==1.0.0
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
PyBluez==0.18
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
subprocess32==3.2.7
tzupdate==1.2.0
urllib3==1.22

The solution: Uninstall scapy-python3

sudo pip uninstall scapy-python3

The output looks like this:

Uninstalling scapy-python3-0.23:

[…] long list of files […]

Proceed (y/n)? y
_ Successfully uninstalled scapy-python3-0.23_

And then reinstall the correct scapy version:

sudo pip install scapy

The output looks like this:

Collecting scapy
_ Downloading scapy-2.3.3.tgz (1.4MB)_
_ 100% |████████████████████████████████| 1.4MB 75kB/s_
Building wheels for collected packages: scapy
_ Running setup.py bdist_wheel for scapy … done_
_ Stored in directory: /root/.cache/pip/wheels/bd/cf/05/d5abc9b4434f39ffe231517dfb8dab96241fef6a99459051f9_
Successfully built scapy
Installing collected packages: scapy
Successfully installed scapy-2.3.3

Now you are ready to go :slight_smile:

Thank you @MahatmaX :slight_smile: It is very important for me to have feedback from users.

I dont know where i go wrong.

I had this script running but after the last update it won’t start after i reboot my Pi.

I get this error

    systemctl status dash.service
dash.service - Amazon Dashbutton Reader
Loaded: loaded (/etc/systemd/system/dash.service; enabled)
Active: failed (Result: start-limit) since Mon 2018-08-06 10:43:59 CEST; 12min ago
Process: 1344 ExecStart=/usr/bin/python /etc/openhab2/scripts/dashbutton/dash.py (code=exited, 
status=1/FAILURE)
Main PID: 1344 (code=exited, status=1/FAILURE)

The rights of my servicefile looks like this:
-rwxr-xr-x 1 root root 208 Mar 6 11:09 dash.service

And this rights of my dash.py looks like this:
-rwxrw-rw- 1 openhabian openhabian 1445 Aug 2 10:25 /etc/openhab2/scripts/dashbutton/dash.py

When i start it manually with sudo systemctl start dash.service the service runs well until i reboot my Pi.

Where is the error?

EDIT (07.08.18): It seems like the service crashes when i press the DashButton too. Yesterday evening i try to press the button and the service status says that the service faild at that time (17:14). Mayby that is a hint for the solution.

After upgrading to a new raspberry image with openhab 2.3 I am getting similar errors like @NilsAcht.
I tried to start the diagnostics:

 sudo amazon-dash run --config /etc/amazon-dash.yml

I am getting:

Welcome to Amazon-dash v1.1.1 using Python 2.7.13
Listening for events. Amazon-dash will execute the events associated with the registered buttons.
Traceback (most recent call last):
  File "/usr/local/bin/amazon-dash", line 6, in <module>
    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 99, in run
    from amazon_dash.listener import Listener
  File "/usr/local/lib/python2.7/dist-packages/amazon_dash/listener.py", line 6, in <module>
    from amazon_dash.confirmations import get_confirmation
  File "/usr/local/lib/python2.7/dist-packages/amazon_dash/confirmations.py", line 5, in <module>
    from amazon_dash._compat import JSONDecodeError
  File "/usr/local/lib/python2.7/dist-packages/amazon_dash/_compat.py", line 18, in <module>
    import subprocess32 as subprocess
ImportError: No module named subprocess32

@Nekmo: May be it’s together with the python version?

@BigMountainSki this is an error on Piwheels:

It should already be solved. Maybe you have cached the corrupt package:

pip install -I --no-cache-dir amazon-dash

1 Like

Thank you - thats the solution.

I tryed it and get these lines:

[13:34:05] openhabian@openHABianPi:~$ sudo pip install -l -no-cache-dir amazon-dash
[sudo] password for openhabian: 
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
  load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point
  return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point
  return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load
  ['__name__'])
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 71, in <module>
  from pip.exceptions import InstallationError, CommandError, PipError
EOFError: EOF read where object expected
[13:34:30] openhabian@openHABianPi:~$ sudo python pip install -l -no-cache-dir amazon-dash
python: can't open file 'pip': [Errno 2] No such file or directory

Sorry but i don’t understand this. Was it succsessful?

I did execute the same thing. Also not sure if this worked as there is an error message at the end:

sudo pip install -I --no-cache-dir amazon-dash

dash
[sudo] password for openhabian:
Traceback (most recent call last):
File “/usr/bin/pip”, line 9, in
load_entry_point(‘pip==1.5.6’, ‘console_scripts’, ‘pip’)()
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 356, in load_en try_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 2476, in load_e ntry_point
return ep.load()
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 2190, in load
[‘name’])
File “/usr/lib/python2.7/dist-packages/pip/init.py”, line 74, in
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File “/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py”, line 9, in
from pip.download import path_to_url
File “/usr/lib/python2.7/dist-packages/pip/download.py”, line 25, in
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead

always hard to try to fix something without understanding what the technical background actually is … :wink:

could someone help us please? I restarted the raspi and still see the same initializing status. Also after deleting the thing and adding it again it goes at Initializing after some hours.

I am using Openhab 2.3.0-1 on a raspberrypi 3 Model B

I have to admit that I dont find a amazon-dash.yml file so not sure if my setup is even the right one for this thread.

Hi Jens,

I tried your approach as I have the same issue with the binding. So I uninstalled the binding and followed your instructions.

When checking the status of the dash.service I noticed that it was deactivated by a start-limit

Active: failed (Result: start-limit) since Sun 2018-08-19 08:02:00 CEST; 14min ago

I did not research and tried to solve this with some more settings int he dash.service:

[Unit]
Description=Amazon Dashbutton Reader

[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/bin/python /etc/openhab2/scripts/dashbutton/dash.py
Restart=always
LimitIntervalSec=0
StartLimitBurst=1000

[Install]
WantedBy=multi-user.target

When I check the status of the service now it is at least active but I see it often in “activating” status as it is restarting frequently. I guess this is an issue as it will not capture the Dashbutton when it is not active all the time.

Can you please let me know how you fixed this with the restart limit?

EDIT: Issue fixed after I saw a post with a similar error that was solved by installing scapy. Although Ii did it according to the tutorial a fresh install worked then. Thanks for this solution!

Thanks,
Martin

This seems to be an error in your Python installation or a problem in your machine. The error is in Pip, it is not an Amazon-dash error.

Same here. This is a error on Pip/Python.

One question to the users of Jen‘s solution. What lag do you see between pressing the button and seeing the action happen?

When accessing the Amazon servers is allowed:
For me it takes 5-10 seconds to see the action in my house and the button keeps on flashing with a red light for up to 20 seconds more until I can press it again. I also sometimes receive messages from amazon that I should complete the setup.

When accessing the Amazon servers is blocked:
Again the action takes 5-10 seconds and the button keeps flashing white for 30 seconds more until I can use it again. I guess it keeps trying to get an answer from AWS.

Can you confirm similar lags?