Amazon Dash Button

Begonnen von gloob, 31 August 2016, 08:20:07

Vorheriges Thema - Nächstes Thema

Ralf W.

#120
Hallo,

hier mal meine Sparvariante:
sudo dhcpdump -i br0 | awk ' /IP:/ { if ($3 == "(44:65:d:93:94:73)") system("echo setreading DASH Sagrotan pressed | socat -t50 - TCP:fhem:7072") }'

MfG

Edit:
Manchmal schickt das Ding zwei mal den Request raus. Dafür dem Reading die Uhrzeit mitgeben:
sudo dhcpdump -i br0 | awk ' /IP:/ { if ($3 == "(44:65:d:93:94:73)") system("echo setreading Dash Sagrotan `date +%R:%M` pressed | socat -t50 - TCP:fhem:7072") }'
Proxmox Nipogi AM16, FHEM:RaspberryMatic:DE ConBee II, diverse Sensoren und Aktoren.

CarstenF

Also jetzt habe ich die Lan-Ping Methode mal probiert, die scheint auch zu laufen.
Jedoch machen die User Readings laufend Fehlermeldungen ins Logfile.
ast_present
Error evaluating DASH_Brabantia userReading last_present: Undefined subroutine &main::presence_last_present called at (eval 753189) line 1.
2016-09-10 12:00:47
last_present_h
Error evaluating DASH_Brabantia userReading last_present_h: Undefined subroutine &main::seconds_humanreadable called at (eval 753191) line 1.
2016-09-10 12:00:47
last_present_s
Error evaluating DASH_Brabantia userReading last_present_s: Undefined subroutine &main::presence_absent_since called at (eval 753190) line 1.
2016-09-10 12:00:47

Eingetragen habe ich die so:
last_present { presence_last_present($NAME) }, last_present_s { presence_absent_since($NAME) }, last_present_h { seconds_humanreadable(ReadingsVal($NAME, 'last_present_s', 0)) }
Sieht jemand den Fehler?
Gruß Carsten
Raspberry Pi4
CUL 868, CUL 433, LaCrosse Gateway, Zigbeetomqtt2, HUE, Homematic
Max-Cube umgeflasht
MAX!, FhemtoFhem, Homebridge, FhemConnector, IR_Gateway und sonst auch noch allerlei Spielzeug....

fh168

@Carsten, ich habe den gleichen Fehler. Siehe ein paar Posts vorher :-)
Hue, Lacrosse, PCA301, MySensors, V 1.67 CUL 868 V3.4, Lacrosse-WLAN-Gateway, Tasmota RF-

CarstenF

Jo, stimmt. Wald vor lauter Bäumen.....


Gesendet von iPad mit Tapatalk
Raspberry Pi4
CUL 868, CUL 433, LaCrosse Gateway, Zigbeetomqtt2, HUE, Homematic
Max-Cube umgeflasht
MAX!, FhemtoFhem, Homebridge, FhemConnector, IR_Gateway und sonst auch noch allerlei Spielzeug....

betateilchen

Zitat von: CarstenF am 10 September 2016, 12:27:56
Sieht jemand den Fehler?

Zitat von: fh168 am 10 September 2016, 17:37:00
ich habe den gleichen Fehler.

Die von Euch verwendeten Funktionen


presence_last_present()
presence_absent_since()
seconds_humanreadable()


gibt es nicht in fhem.

ich könnte ja nun einfach mal auf planloses Abschreiben bzw. copy&paste tippen...
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

CarstenF

Tja, hast Du wohl Recht. Etwas naiv. Werde mich heute Nacht mal damit beschäftigen.


Gesendet von iPad mit Tapatalk
Raspberry Pi4
CUL 868, CUL 433, LaCrosse Gateway, Zigbeetomqtt2, HUE, Homematic
Max-Cube umgeflasht
MAX!, FhemtoFhem, Homebridge, FhemConnector, IR_Gateway und sonst auch noch allerlei Spielzeug....

betateilchen

Der Dash Button und die Presence-Erkennung funktionieren natürlich völlig problemlos auch ohne diese userReadings.
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

bendim

#127
Bei mir läuft die Node.js Variante ganz gut. Hier eine ausführliche Anleitung, für die sich nicht ganz so gut auskennen.
https://maker-tutorials.com/fhem-geraete-mit-amazon-dash-button-schaltensteuern-raspberry-pi-home-automation/

Es werden die Node.js Scripte node-dash-button und dasher verwendet. Dasher wird dann als Service im Hintergrund ausgeführt (verbraucht fast keine Systemresourcen). Dasher lauscht nach ARP Request und sendet dann ein Post Request an FHEM.
Es können beliebig viele Dash Buttons eingebunden werden.
Verzögerung ist ca. 5-6 Sekunden, aber ich habe schon gelesen das man das reduzieren kann.

CarstenF

Also, um ein "Last Present" Reading zu erhalten habe ich jetzt folgendes UserReading eingefügt. Das erzeugt einen Zeitstempel im Reading, so das man weiß, wann der Knopf als letztes gedrückt wurde.

lastpresent {if (Value("DASH_Brabantia") eq "present") {ReadingsTimestamp("DASH_Brabantia", "state", "false")} else {ReadingsVal("DASH_Brabantia","lastpresent","")}}




Gesendet von iPad mit Tapatalk
Raspberry Pi4
CUL 868, CUL 433, LaCrosse Gateway, Zigbeetomqtt2, HUE, Homematic
Max-Cube umgeflasht
MAX!, FhemtoFhem, Homebridge, FhemConnector, IR_Gateway und sonst auch noch allerlei Spielzeug....

Wzut

@Andre :
WARNING: unsupported character in reading a8:e3:ee:37:fc:5a (not A-Za-z/\d_\.-), notify the dash_dhcp module maintainer.
Wechseln zur Windoof MAC Darstellung   a8-e3-ee-37-fc-5a oder Cisco Schreibweise  a8e3.ee37.fc5a
oder gleich ganz kompakt  a8e3ee37fc5a ?
Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

justme1968

ups. da war noch was.

ich denke - 

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

justme1968

ich habe die version hier: https://forum.fhem.de/index.php/topic,57248.msg488553.html#msg488553 aktualisiert. es wird jetzt ein - statt des : verwenden.

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

simonberry

Hallo Wzut,

ich habe Deine Version aus dem Post
https://forum.fhem.de/index.php/topic,57248.msg488371.html#msg488371
am Wochenende bei mir eingebaut, vor allem weil Du so eine tolle Anleitung geschrieben hast. Es hat auch wunderbar funktioniert, bis heute Nacht.
Ich habe heute Nacht eine Sicherung von meinem FHEM gemacht, und dabei fahre ich FHEM immer herunter, seit dem Neustart sieh das DashB Device folgendermaßen aus:

Internals:
   NAME       myDash
   NR         577
   STATE      error
   TYPE       DashB
   Readings:
     2016-09-12 13:57:12   error           eth0: You don't have permission to capture on that device (socket: Die Operation ist nicht erlaubt)
     2016-09-10 13:31:38   mac_xxxxxxxxxxxx present
     2016-09-10 13:32:07   mac_xxxxxxxxxxxx present
     2016-09-10 13:31:41   mac_xxxxxxxxxxxx present
     2016-09-10 13:31:41   mac_xxxxxxxxxxxx present
     2016-09-10 13:31:38   mac_xxxxxxxxxxxx present
     2016-09-11 20:51:08   mac_xxxxxxxxxxxx present
     2016-09-10 13:26:52   mac_xxxxxxxxxxxx present
     2016-09-10 13:31:52   mac_xxxxxxxxxxxx present
     2016-09-10 13:26:04   mac_xxxxxxxxxxxx present
     2016-09-10 13:32:08   mac_xxxxxxxxxxxx present
     2016-09-10 13:32:08   mac_xxxxxxxxxxxx present
     2016-09-10 13:31:41   mac_xxxxxxxxxxxx present
     2016-09-12 13:57:12   state           error
   Helper:
Attributes:
   interface  eth0
   room       Technik,Test



Die Raspi (B2) lief dabei durch.

Hast Du, oder jemand anders eine Idee?

Vielen Dank
Simonberry
NUC5i3RYK#DBLOG; MYSQL; LIRC; MPD; HM-CFG-HM-USB-2: HM-divers; MQTT2; Signalduino; Shelly; Sonoff; dash_dhcp; FS20; IT; FroniusWR; Somfy RTS; NFS-Server
Rpi B#: nfsmount; ser2net CUL868; CUL433; GPIO4:DS18B20; WEMOS-D1-MINI#JVC-via-IR;

Wzut

Zitat von: simonberry am 12 September 2016, 14:00:35
error           eth0: You don't have permission to capture on that device (socket: Die Operation ist nicht erlaubt)
da liegt der Hund begraben, bzw dein User hat keine Rechte auf eth0 was man aber erlauben kann mittels:
sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/perl
Musste ich bisher noch nicht einmal wiederholen, allerdings habe ich mein Modul z.Z verbannt da der NonBlocking Prozess auf meinem Testsystem permanent mit 100% Last lief.
Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

Mitch

Zitat von: justme1968 am 06 September 2016, 16:42:29
anbei mal eine erste version eines moduls das die oben beschriebene dhcp variante verwendet. es sind keine perl zusatz module nötig.

- define anlegen mit: define dash dhcp_dash
- wenn fhem nicht als root läuft: die oben vorgeschlagene  iptables regel verwenden und das port attribut passend setzen
- in allowed die liste der erlaubten mac adressen setzen
- das modul legt für jeden erlaubten button ein reading mit der mac adresse an und dem inhalt short wenn die adresse erkannt wird.

gruss
  andre

ps: völlig ungetestet. mein dash button ist immer noch eingepackt :)

edit  2016-09-16: die readings verwenden jetzt einen - statt eines :

Hi Andre,

abgesehen davon, dass der define define dash dash_dhcp lauten muss, erzeugt das Module Fehler im Log:

2016.09.12 16:00:09.557 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:59:59.550 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:59:49.545 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:59:39.537 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:59:29.532 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:59:19.524 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:59:06.486 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:58:56.480 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:58:46.482 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:58:36.476 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:58:26.479 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:58:16.472 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:58:02.799 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:57:52.793 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:57:42.786 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:57:32.775 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:57:22.779 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:57:12.772 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:56:59.813 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:56:49.808 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.
2016.09.12 15:56:39.802 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at ./FHEM/30_dash_dhcp.pm line 88.


Habe ich etwas falsch gemacht?
FHEM im Proxmox Container