After that i tried again, but without sudo, i got errors. Next try with sudo - see the output below… Is this ok?
debian@debian:~$ /usr/bin/python /etc/openhab2/scripts/dashbutton/dash.py
WARNING: No route found for IPv6 destination :: (no default route?)
Traceback (most recent call last):
File "/etc/openhab2/scripts/dashbutton/dash.py", line 37, in <module>
print sniff(prn=arp_display, store=0,count=0)
File "/usr/lib/python2.7/dist-packages/scapy/sendrecv.py", line 561, in sniff
s = L2socket(type=ETH_P_ALL, *arg, **karg)
File "/usr/lib/python2.7/dist-packages/scapy/arch/linux.py", line 451, in __init__
self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))
File "/usr/lib/python2.7/socket.py", line 187, in __init__
sock = _realsocket(family, type, proto)
socket.error: [Errno 1] Operation not permitted
debian@debian:~$ sudo /usr/bin/python /etc/openhab2/scripts/dashbutton/dash.py
WARNING: No route found for IPv6 destination :: (no default route?)
As I have not that much expertise in this so far, I wonder where I can find the results of those
syslog.syslog("")
and
print ""
calls. I would like to make sure that the script works. Can you please direct me to the right folder(s) and file(s) where to look? I run an RPi 3 with Raspbian Jessie lite.
The print messages appear only if the script is called directly. The syslog.syslog messages are written to the messages file of Unix that can be monitored like this:
sudo tail -f /var/log/messages
So if you would change the print messages in the script given to:
syslog.syslog("Dash-Button %d detected" % (index +1))
[...]
syslog.syslog("dashbutton: but twice, so ignoring the 2nd call...")
Then you could monitor the messages of the script while it’s running as a service.
Pretty new to openhab, so if there’s a documentation and I just missed it, please send me there
I have the same problem as everyone else, my dash button keeps initializing. So I use your python-script. It’s working for me.
Problem is, I don’t know what to do next. How do I use the script to trigger one of my rules?
You need corresponding rules for these that look like:
rule MSG_UliLicht
when
Item DashButton2 received update ON
then
logInfo("dash.rules", "DashButton 2 (Uli) wurde gedrückt")
// BEGIN OF ACTION
// Toggle a lamp...
if (V_DG_PY_Buben_Uli.state == ON)
{
V_DG_PY_Buben_Uli.sendCommand(OFF)
}
else
{
V_DG_PY_Buben_Uli.sendCommand(ON)
}
// END OF ACTION
// Reset the state of button, that it will see the next update...
DashButton2.postUpdate(OFF)
end
Replace the actions within that rule with your own logic
I’m very sorry you can not get the dash button up and running with dashbutton binding. I have 15 (!) of them. It happens very rarely and only if I restart the OH server (but not after each restart), that sometimes one or at most two buttons still remain on INITIALIZING. Then I delete these buttons via PaperUI and add them back immediately. Then they work fine again.
Can you please clarify your items definitions? In my rules, I still use
rule "My dash button rule"
when
Channel "amazondashbutton:dashbutton:aa-bb-cc-dd-ee-ff:press" triggered
then
// my logic
end
In the official documentation there is just this thing definition for a button but no definition of an item.
Apart from that, since the implementation of your python script the whole dash handling seems to be working properly for a couple of days now! Many thanks for your work!
That is not the way i want to have my smarthome control running.
A button has to be working. I can´t use a button, which doesn´t work all the time and only works again, when i do something in the backend…
I use the button to open my garage door when i´m out for jogging. So i only have to take the dashbutton with me. If the button is not working when i come home, it would be very bad, because then i don´t come into my house…
The thing definition is only needed for the official amazondashbutton binding. But the new way to implement dashbuttons is completely without this binding, so you only have to make a switch in your items file, which is updated by the dashbutton.
In addition to this, i combined the switch with the expire-binding for 1s. So no need to change the switch back to OFF inside the rule.