[SOLVED] Amazon dash button: Steps for a complete setup

Hi there,

I now have two dash buttons, I’d like to use for OH2. I’m stuck at connecting the binding with pcap4j, I guess.

Ok, what I’ve done so far - I’m using openHABian (raspbian):

  1. sudo apt-get install libpcap-dev
  2. sudo setcap cap_net_raw,cap_net_admin=eip `realpath /usr/bin/java`
  3. added “amazondashbutton” in the addons.cfg in the binding section:
    binding = amazondashbutton, ..
  4. nothing happens

In the readme I don’t see, what to add in a .cfg file or in a .thing file, it tells me, auto detection in PaperUI should work, but this won’t work also.

So, what did I miss? Thanks for your help!

What does not happen? The binding does not get installed? Check via PaperUI Addons if you successfully installed the binding. If not, hit the install button.

Exactly, there is nothing to add. You connect your dash button to your wifi, hit the button once and the “Thing” is automatically added.
Then you trigger the provided channel in a rule:

rule "Dash button pressed"
    when
        Channel "amazondashbutton:dashbutton:ac-63-be-xx-xx-xx:press" triggered
    then
        println("The Dash button has been pressed")
end

If you are unsure what to do: do it exactly as stated in the docs, it works.

sorry, if it was unclear. The Binding is installed and is listed as active in PaperUI and in the console.

this is, what doesn’t happen! :wink: I open up PaperUI, hitting my dashbuttons and they’re not added as Things. So is there a way to add them as Things in a .Thing config file? I’m more a file-guy than a UI-guy! :wink:

@binderth You can try to add dash button manually in PaperUI. Then you can see, if your network interface is available. Please check here:

Maybe the line “Network Interface” is empty or has no pull down list…

Is one or more are available, try them, and fill in MAC address manually.

that’s strange: yesterday it wasn’t possible to add a Thing manually (under the orange Header everything was blank), today I got this:

unfortunately its Status is offline and theres no capture in the rule:

rule "Dash button WaMa pressed"
    when
        Channel "amazondashbutton:dashbutton:c3fe3721:press" triggered
    then
		logInfo("WaMa Button", "WaMa button wurde gedrückt")

end

Mustn’t there be some Kind of Connection between pcap4j and OH2? How does OH2 scan the network if I doesn’t provide it with some path to the executable? or is this ootb? :wink:

1st:
It seems that your pcap4j is not connected to your network interface… but I don’t know exactly how your Network Interface must look like under linux, I’m using Windows and it looks like that:

Please check your pcap4j installation again!

2nd:

And while adding a new Dash Button manually, give ThingID the same like your MAC address:

and then change your rule, too:

Channel "amazondashbutton:dashbutton:84-d6-f7-d5-be-be:press" triggered

Puh. I followed the guide explained here: http://docs.openhab.org/addons/bindings/amazondashbutton/readme.html
Do you know of a “test”, which I can perform in the shell, which would capture something outside of OH2? just to be sure, the configuration is ok?

is there a special need to do this?

I don’t know a testing, sorry. Maybe this could help:

And “Thing ID” = MAC address, when Dash Button automatically was discoverd in inbox. (Using: “simple item linking” in system configuration (in PaperUI).

1 Like

Thanks for your help, but I’m no developer and I don’t know what to do with the sample_SendArpRequest.md you linked. I guess. I just resetted my Dash button and tried again with no luck…

as far as I know, just run the following command (seen in sample_SenderArpRequest.md) in a linux console:

 java -cp pcap4j-core.jar:pcap4j-packetfactory-static.jar:pcap4j-sample.jar:jna-3.5.2.jar:slf4j-api-1.6.4.jar org.pcap4j.sample.SendArpRequest 192.168.209.1

Replace 192.168.209.1 with an existing IP address of something in your network…

If you get the corresponding MAC address, then your pcap4j is OK.

Arghs! One step forward, one step back…

I found in openhab.log:

2017-02-14 16:17:02.491 [ERROR] [nal.capturing.PacketCapturingService] - Capturing packets on device eth0 failed.
org.pcap4j.core.PcapNativeException: eth0: You don't have permission to capture on that device (socket: Operation not permitted)
	at org.pcap4j.core.PcapNetworkInterface.openLive(PcapNetworkInterface.java:258)[208:org.openhab.binding.amazondashbutton:2.1.0.201701231811]
	at org.openhab.binding.amazondashbutton.internal.pcap.PcapNetworkInterfaceWrapper.openLive(PcapNetworkInterfaceWrapper.java:68)[208:org.openhab.binding.amazondashbutton:2.1.0.201701231811]
	at org.openhab.binding.amazondashbutton.internal.capturing.PacketCapturingService.startCapturing(PacketCapturingService.java:86)[208:org.openhab.binding.amazondashbutton:2.1.0.201701231811]
	at org.openhab.binding.amazondashbutton.handler.AmazonDashButtonHandler.initialize(AmazonDashButtonHandler.java:69)[208:org.openhab.binding.amazondashbutton:2.1.0.201701231811]
	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.thingUpdated(BaseThingHandler.java:192)[105:org.eclipse.smarthome.core.thing:0.9.0.201701192225]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$7.call(ThingManager.java:522)[105:org.eclipse.smarthome.core.thing:0.9.0.201701192225]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$7.call(ThingManager.java:1)[105:org.eclipse.smarthome.core.thing:0.9.0.201701192225]
	at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:179)[98:org.eclipse.smarthome.core:0.9.0.201701192225]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

strange thing: this was before I updated to the latest Snapshopt (#789) today. After upgrading, the only Thing referring to the dashbutton in the openhab.log are:

2017-02-14 18:06:29.531 [WARN ] [ome.core.thing.internal.ThingManager] - Initializing handler for thing 'amazondashbutton:dashbutton:c3fe3721' takes more than 5000ms. `

So I checked the permission again:

[18:40:40] pi@openHABian2:~$ sudo getcap `realpath /usr/bin/java`
/usr/lib/jvm/java-8-oracle/jre/bin/java = cap_net_admin,cap_net_raw+eip cap_net_bind_service+ep

and after restart of openhab2 I get These:

...
2017-02-14 18:56:55.245 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2017-02-14 18:57:06.211 [WARN ] [org.pcap4j.util.PropertiesLoader    ] - [org/pcap4j/pcap4j.properties] Could not get value by org.pcap4j.af.inet, use default value: null
2017-02-14 18:57:06.215 [WARN ] [org.pcap4j.util.PropertiesLoader    ] - [org/pcap4j/pcap4j.properties] Could not get value by org.pcap4j.af.inet6, use default value: null
2017-02-14 18:57:06.218 [WARN ] [org.pcap4j.util.PropertiesLoader    ] - [org/pcap4j/pcap4j.properties] Could not get value by org.pcap4j.af.packet, use default value: null
2017-02-14 18:57:06.221 [WARN ] [org.pcap4j.util.PropertiesLoader    ] - [org/pcap4j/pcap4j.properties] Could not get value by org.pcap4j.af.link, use default value: null
2017-02-14 18:57:06.453 [WARN ] [org.pcap4j.util.PropertiesLoader    ] - [org/pcap4j/pcap4j.properties] Could not get value by org.pcap4j.dlt.raw, use default value: null
2017-02-14 18:57:08.102 [INFO ] [b.core.service.AbstractActiveService] - HTTP Refresh Service has been started
...

seems I have some issues getting pcap4j to work.

PS: I tried your command, but get:

[19:00:15] pi@openHABian2:~/bsp$  java -cp pcap4j-core.jar:pcap4j-packetfactory-static.jar:pcap4j-sample.jar:jna-3.5.2.jar:slf4j-api-1.6.4.jar org.pcap4j.sample.SendArpRequest 192.168.209.1
Error: Could not find or load main class org.pcap4j.sample.SendArpRequest

I downloaded sample_SendArpRequest.md in the ~/bsp directory, do I have to load the class somehow?

Just as I wanted to test something new, it worked!
in snapshot #789 I wanted to add the dash-button as a Thing via PaperUI and it didn’t work - and in the dialogue I couldn’t even add all the Attributes.
I updated again (after moving from bintray to jfrog), this time to #791 and it found the Thing automatically!

So, now I did it! Perhaps it was like @Celaeno1 said: the Thing should be named like the MAC-address - or it was something in my old snapshot (#776 if i remember correctly), whatever now it works.

Just for others to wonder, the steps:

  1. sudo apt-get install libpcap-dev
  2. sudo setcap cap_net_raw,cap_net_admin=eip `realpath /usr/bin/java`
  3. added “amazondashbutton” in the addons.cfg in the binding section:
    binding = amazondashbutton, ..
  4. in PaperUI you can now add the Thing with autodetection (press button of the dashbutton)

now you see the Thing in PaperUI and can paste it in the rule.

Hi,

I had also some trouble getting my dash button recognized as a Thing in PaperUI (at the inbox) on my openHABian. I followed the instructions in your last post but no luck.
Finally after a reboot it worked immediately, so I suppose a restart is needed on the openHABian for any reason.

Thanks for the thread id helped me a lot.

1 Like

Hi there,

I am getting the same error, but no solution in here could my problem.

openhab@smartVM:~$ java -cp pcap4j-core.jar:pcap4j-packetfactory-static.jar:pcap4j-sample.jar:jna-3.5.2.jar:slf4j-api-1.6.4.jar org.pcap4j.sample.SendArpRequest 192.168.178.60
Error: Could not find or load main class org.pcap4j.sample.SendArpRequest

I tried to reinstall the libpcap-dev package with

sudo apt-get install --reinstall libpcap-dev

and also tried to purge and install it again.
Also rebooting - no help.

sudo getcap realpath /usr/bin/java

gives me

/usr/lib/jvm/java-8-oracle/jre/bin/java = cap_net_admin,cap_net_raw+eip cap_net_bind_service+ep

Running Ubuntu at a VM with Openhab2 Version info:

openHAB Distribution Version Information
----------------------------------------
build-no        : - release build -
online-repo     : https://dl.bintray.com/openhab/mvn/online-repo/2.1

Repository        Version
----------------------------------------
openhab-distro  : 2.1.0
smarthome       : 0.9.0.b5
openhab-core    : 2.1.0
openhab1-addons : 1.10.0
openhab2-addons : 2.1.0
karaf           : 4.0.8

Installed Dash button binding via paper UI, did not add the binding as told in step 3 to addons.cfg because I understood that as thing to do for first time setup, and neither did that with other bindings which are working fine.
Maybe thats my fault.

I would really appreciate your help.

Hi, did you find a solution yet?

I do have a similar problem, as my dash buttons won’t initialize:

It seems, my libpcap-dev is working also with the correct rights:

[15:03:45] openhabian@openHABianPi:~$ sudo getcap `realpath /usr/bin/java`
/usr/lib/jvm/zulu-embedded-8-armhf/bin/java = cap_net_admin,cap_net_raw+eip cap_net_bind_service+ep

I also get the error-message:

[15:18:36] openhabian@openHABianPi:~$ java -cp pcap4j-core.jar:pcap4j-packetfactory-static.jar:pcap4j-sample.jar:jna-3.5.2.jar:slf4j-api-1.6.4.jar org.pcap4j.sample.SendArpRequest 192.168.178.60
Fehler: Hauptklasse org.pcap4j.sample.SendArpRequest konnte nicht gefunden oder geladen werden

Sadfully no…

@walterwampe @binderth I’m not a linux specialist, but maybe you should first check if the following is on your PC:

pcap4j-core.jar
pcap4j-packetfactory-static.jar
pcap4j-sample.jar
jna-3.5.2.jar
slf4j-api-1.6.4.jar
org.pcap4j.sample.SendArpRequest

If not, then above command makes no sense! Maybe you also have other versions of the xxx.jar files?

  • /srv/openhab2-userdata/cache/org.eclipse.osgi/188/0/.cp/lib/pcap4j-core-1.6.6.jar
  • /srv/openhab2-userdata/cache/org.eclipse.osgi/188/0/.cp/lib/pcap4j-packetfactory-static-1.6.6.jar
  • /var/lib/openhab2/cache/org.eclipse.osgi/188/0/.cp/lib/pcap4j-core-1.6.6.jar
  • /var/lib/openhab2/cache/org.eclipse.osgi/188/0/.cp/lib/pcap4j-packetfactory-static-1.6.6.jar
  • /srv/openhab2-userdata/cache/org.eclipse.osgi/188/0/.cp/lib/jna-4.2.1.jar
  • /var/lib/openhab2/cache/org.eclipse.osgi/188/0/.cp/lib/jna-4.2.1.jar
  • /srv/openhab2-sys/runtime/system/org/slf4j/slf4j-api/1.7.12/slf4j-api-1.7.12.jar
  • /srv/openhab2-sys/runtime/system/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar
  • /usr/share/openhab2/runtime/system/org/slf4j/slf4j-api/1.7.12/slf4j-api-1.7.12.jar
  • /usr/share/openhab2/runtime/system/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar

I neither find “pcap4j-sample.jar” nor “org.pcap4j.sample.SendArpRequest”…

Ok, now I know, the above command makes no sense, as I seem to not have samples! :wink: Is there a way to check the libpcap-Installation? As I wrote in my thread, the dashbutton worked for a day or to and then stopped - neither reboot nor OH2-restart seem to help…

Did you set up your dash button with the amazon app or did you nothing?