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

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?

as described in the docs: I stopped at the last step within the amazon app. After that, it worked for a day or two…

Maybe DHCP gave it a new IP? Have you tried a fixed IP for the dashbutton?

@binderth SendArpRequest is a .class inside pcap4j-sample.jar.
Maybe the only thing is missing is: pcap4j-sample.jar. But I don’t know if you can find one which is corresponding to your installation. You can find it e.g. here:

https://mvnrepository.com/artifact/org.pcap4j/pcap4j-sample.

I guess version 1.6.6 is fitting to your pcap4j-core-1.6.6.jar

Then your command could be (but I don’t really know!!) like this:

java -cp pcap4j-core-1.6.6.jar:pcap4j-packetfactory-static-1.6.6.jar:pcap4j-sample-1.6.6.jar:jna-4.2.1.jar:slf4j-api-1.7.12.jar org.pcap4j.sample.SendArpRequest 192.168.178.60

or

java -cp pcap4j-core-1.6.6.jar:pcap4j-packetfactory-static-1.6.6.jar:pcap4j-sample-1.6.6.jar:jna-4.2.1.jar:slf4j-api-1.7.7.jar org.pcap4j.sample.SendArpRequest 192.168.178.60

@binderth

Maybe this is why your dash button doesn´t work anymore?

What is your Model No. ?

I bought 5 new Dash Buttons (in Germany) 4 weeks ago. They are all running! But I had to add them manually. I just filled in the MAC-Address!

Can you tell me how you will use the buttons? I have some dash buttons running and no ideas where I can use them everywhere.

I use them all as a switch. For turning on/off: Lights, Hifi, Wifi-Sockets, switching actions for Harmony Hub, and so on…

Did you add them in the PaperUI as Things?
I configured them solely via config-files - After some digging into the case, I learned, the binding doesn’t need the dash buttons as a Thing, just in a rule, so I deleted them from my .thing configuration file and only have them in the rules - but as expected this didn’t change anything… They don’t fire as they did just after the Installation…

I don’t think mine go into factory reset or anything - as the appear online in my Fritz.Box UI and I can ping them, if activated - so I assume some configuration issues within OH2…
My model numbers are also JK29LP for the five new ones - the old ones are glued to my washing machine and dryer and I don’t want to remove them! :wink:

Did you add them in the PaperUI as Things?

Yes, I configured them via PaperUI. I don’t have a .things file for my Dash Buttons. My older ones were detected by searching in inbox (PaperUI -->inbox --> “Search for things” --> “Amazon Dash Button Binding” --> Pressing my new Dash Button once --> then it was detected automatically and shown in inbox -->click on the blue hook --> add as thing.
My newer ones: I had to do an other procedure: PaperUI --> inbox–> “Search for things” --> “Amazon Dash Button Binding” --> Pressing my new Dash Button once -->nothing is shown in inbox -->Add manually --> “Amazon Dash Button” --> Configuration --> Select network interface --> fill in MAC-Address! MAC-Address format is: 00:80:41:ae:fd:7e That’s it!

1 Like