I guess
sudo apt-get install tcpdump
should do the trick.
I guess
sudo apt-get install tcpdump
should do the trick.
This helped only partial…
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 6, in <module>
import requests, datetime
ImportError: No module named requests
I don´t use ipv6, only ipv4.
Can this be because of a wrong python version?
I use Debian Jessie, all updates up to date. There is python 2 inside, i think?
Do i have to import the “requests” in any other way?
Or do i have to install another python version?
I tried:
sudo apt-get install requests
But i get an error: could not be found…
I think i got it:
The right command to solve this was:
sudo apt-get install python-requests
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?)
I am away from my homebase in the moment, I will check your messages tonight…
Ok, but i can say, it works now, even with this warning!
Thank you.
EDIT:
Saw your edited instructions…
This is still missing:
sudo apt-get install tcpdump
Glad to hear!
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.
You might need to restart the script with
sudo service dash restart
to apply changes you made to the source.
Perfect - thank you very much for your detailed answer!
I assume that there is no way to add those messages to the openhab.log. Is that correct? It would be quite handy to use
sudo tail -f /var/log/openhab2/openhab.log
to watch them as well.
Well there is, you would need to use the log4j capabilities of python - as I did not have the need I did not investigate this further.
If you would like to give it a try yourself, have a look at https://wiki.python.org/jython/Log4jExample
Alright, thank you!
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?
If you have a look at the script you will see for each dashbutton a corresponding openhab item name, i.e.
dash_item = ("DashButton1", "DashButton2", "DashButton3")
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
Hi folks,
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.
Can you please post a short example? Thank you!
items-file:
// Amazon Dash button
Switch Amazon_dashbutton_1 "Amazon Dashbutton Schwarzkopf - 1" { expire="1s,command=OFF" }
rules-file:
rule "Dash button pressed - python script"
when
Item Amazon_dashbutton_1 changed to ON
then
logInfo("RULES", "Amazon Dash Button pressed py-Script - state: " + Amazon_dashbutton_1)
sendCommand(another-switch-item, ON)
end