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
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
One additional note:
If you use the python-way to control the dashbutton, you can uninstall the dasbutton binding and the things-definition.
Your rule with “amazondashbutton… gets triggered” uses still the binding, not the python script.
Okay, thank you very much!
I did not know that. I guess this detail (the items definition) is missing in the posting above. Maybe this could be added.
Done
Here I never got it working reliably - every time I rebooted there were different dash buttons that weren’t working, and after some uptime often others would fail, too. I’ve now given up on this junk and recycled the dash buttons, this way at least I got a working AAA-battery out of each.
I can’t get the dashbutton to work. So I want to test if the script is working. I tried to change and restart the script to see if I could monitor the messages of the script. But there are no messages.
Is my (your) script correct like this?
#!/usr/bin/python
# -*- coding: utf-8 -*-
from scapy.all import *
import sys, os
import requests, datetime
import syslog
import sys
def arp_display(pkt):
if pkt.haslayer(DHCP):
print (pkt[Ether].src)
for index in range(len(dash_mac)):
if pkt[Ether].src == dash_mac[index]: #die MAC Adresse des Button mit Kleinbuchstaben!
syslog.syslog("Dash-Button %d detected" % (index +1))
if (time.time() - dash_last[index]) > 5.0:
dash_last[index] = time.time()
url = ohabserver + dash_item[index] + "/state"
s = "ON"
print url +"=" + s
try:
myResponse = requests.put(url, s)
except:
syslog.syslog("Fehler beim Abruf von %(url)s : %(status)s" % {"url":url, "status":myResponse.status_code} )
else:
syslog.syslog("Aber doppelt, deswegen ignoriert...")
reload(sys)
sys.setdefaultencoding("utf-8")
# MODIFY THE FOLLOWING LINES ACCORDING TO YOUR NEEDS AND YOUR ENVIRONMENT
# The URL of your openhab-installation
ohabserver = "http://192.168.178.68:8080/rest/items/"
# The MAC addresses of the dashbuttons
dash_mac = ("00:fc:8b:9e:03:b6")
# The item-names of the corresponding Dashboard entries in openhab
dash_item = ("africola")