Unfortunately, like I said above, the Dash script isn’t fully working. I’ve made some updates for things I know were wrong but I’ve not managed to test them fully. I’ve locked down my network and I can’t seem to be able to sniff the ARP packets anymore to do the tests and I’ve not had time to go back and test this.
That being said, the error is caused because the sniffing script is receiving a non-ARP packet You can try changing the code as follows and see if that makes a difference.
Try adding in a check to make sure that the packet is an ARP before trying to get at the data:
#!/usr/bin/python
from scapy.all import *
def arp_display(pkt):
if ARP in pkt:
if pkt[ARP].op == 1: #who-has (request)
if pkt[ARP].psrc == '0.0.0.0': # ARP Probe
print "ARP Probe from: " + pkt[ARP].hwsrc
print sniff(prn=arp_display, filter="arp", store=0, count=30)
This check is already in place in the dash.py code, it is only missing in the getMac.py script.
From default.ini:
[Sensor5]
Class: dash.dash
Connection: MQTT
; One Address/Destination pair per button, start with 1, increment numbers
; Mac address
Address1: 12:34:56:78:90:12
Destination1: actuators/bounty
Address2: 21:09:87:65:43:21
Destination2: actuators/tide
; -1 means this sensor doesn't need to use the main polling thread, it polls on
; its own
Poll: -1
The MAC addresses are listed as Address1, Address2, etc. Each button has its own unique MAC which you put into this parameter. Coupled with each AddressX parameter there is a DesinationX. If you are using the MQTT connection, this is the topic that the word “Pressed” will be published to when that Dash button’s ARP packet has been detected. If you are using REST, this is the Item name of the Item that represents that particular Dash button in openHAB and to which the word “Pressed” will be pushed when the button’s ARP packet is detected.
So in the example in default.ini, there are two Dash buttons.
Address1: 12:34:56:78:90:12 ; MAC address of the Bounty button as determined via getMac.py or some other means
Destination1: actuators/bounty ; MQTT topic that corresponds with the Bounty button
Address2: 21:09:87:65:43:21 ; MAC address of the Tide button
Destination2: actuators/tide ; MQTT topic that corresponds with the Tide button
Hopefully, as you can see now, the mapping takes place in the .ini file. openHAB never needs to know anything about the MAC address. It just needs to know about the MQTT topic.
Let me know if you get this to work. I’ll update the repo with the change to the getMac.py script to avoid that error now but I’d love to know whether or not it works so I can update the description.