HTTPMOD Syntax für Ansteuerung homebridge-videodoorbell

Begonnen von osbs, 09 Dezember 2018, 18:28:13

Vorheriges Thema - Nächstes Thema

osbs

Das Homebridge Modul "homebridge-videodoorbell" kann per HTTP Aufruf angesteuert werden. Es wird das Klingeln ausgelöst.

You can trigger a HomeKit rich notification from outside with a simple curl command: curl -X POST -d 'ding=dong&dong=ding' http://IP_OF_HOMEBRIDGE_RUNNING_DEVICE:PORT_DEFINED_IN_CONFIG

Ich würde gerne per FHEM das Klingeln auslösen. Dafür muss man meines Erachtens per HTTPMOD die Analogie zu dem oben gezeigten curl Befehl herstellen.

HTTPMOD Modul habe ich angelegt:
define Video_Doorbell HTTPMOD http://123.456.7.8:5005 0
attr Video_Doorbell get01Name klingel2homekitget
attr Video_Doorbell get01URL http://123.456.7.8:5005
attr Video_Doorbell get01Data ding=dong&dong=ding

Evtl ist es auch ein set Befehl für den HTTP Post Befehl?
attr Video_Doorbell set01Name klingel2homekitset
attr Video_Doorbell set01URL http://123.456.7.8:5005
attr Video_Doorbell set01Data ding=dong&dong=ding
attr Video_Doorbell set01NoArg 1

Die richtige Syntax fehlt mir und kann ich auch nicht anhand Commandref und Wiki für mich rausarbeiten.
set und get funktionieren nicht, der curl Befehl funktioniert.
Es fehlt sicherlich die richtige Syntax des HTTPMOD Aufrufs, danach wird es funktionieren. Bin für jeden Tipp dankbar.

amenomade

#1
M.A. bist Du nicht weit. Somit sollte es gehen
define Video_Doorbell HTTPMOD none 0
attr Video_Doorbell get01Name klingel2homekitget
attr Video_Doorbell get01URL http://123.456.7.8:5005
attr Video_Doorbell get01Data ding=dong&dong=ding


dann sollte get Video_Doorbell klingel2homekitget klingen lassen

Es kann sein, dass Headers noch benötigt werden. Mach mal noch -v in deinem funktionierenden CURL Kommando, um die Headers zu sehen. Dann die gleiche in attr get01Header01, get01Header02 usw kopieren

Wenn es nicht geht, bitte log mit verbose 5 posten
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

osbs

Super Hinweis mittels -v den curl Befehl näher anzuschauen. Hier das Ergebnis:

curl -v -X POST -d 'ding=dong&dong=ding' http://123.456.7.8:5005
* Rebuilt URL to: http://123.456.7.8:5005/
* Hostname was NOT found in DNS cache
*   Trying 123.456.7.8...
* Connected to 123.456.7.8 (123.456.7.8) port 5005 (#0)
> POST / HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 123.456.7.8:5005
> Accept: */*
> Content-Length: 19
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 19 out of 19 bytes
< HTTP/1.1 200 OK
< Date: Mon, 10 Dec 2018 17:11:11 GMT
< Connection: keep-alive
< Content-Length: 30
<
{"ding":"dong","dong":"ding"}
Connection #0 to host 123.456.7.8 left intact

Auf der Basis habe ich folgendes in fhem eingetragen:
define Video_Doorbell HTTPMOD none 0
attr Video_Doorbell get01Name klingel2homekitget
attr Video_Doorbell get01URL http://123.456.7.8:5005
attr Video_Doorbell get01Data ding=dong&dong=ding
attr Video_Doorbell get01Header01 POST / HTTP/1.1
attr Video_Doorbell get01Header02 User-Agent: curl/7.38.0
attr Video_Doorbell get01Header03 Host: 123.456.7.8:5005
attr Video_Doorbell get01Header04 Accept: */*
attr Video_Doorbell get01Header05 Content-Length: 19
attr Video_Doorbell get01Header06 Content-Type: application/x-www-form-urlencoded


get Video_Doorbell klingel2homekitget funktioniert leider nicht und verbose 5 ergibt:
2018.12.10 21:04:17 5: Video_Doorbell: get called with klingel2homekitget
2018.12.10 21:04:17 5: Video_Doorbell: get found option klingel2homekitget in attribute get01Name
2018.12.10 21:04:17 4: Video_Doorbell: get will now request klingel2homekitget, no optional value
2018.12.10 21:04:17 4: Video_Doorbell: AddToQueue adds get01, initial queue len: 0
2018.12.10 21:04:17 5: Video_Doorbell: AddToQueue adds type get01 to URL http://123.456.7.8:5005, data ding=dong&dong=ding, header POST / HTTP/1.1
User-Agent: curl/7.38.0
Host: 123.456.7.8:5005
Accept: */*
Content-Length: 19
Content-Type: application/x-www-form-urlencoded, retry 0
2018.12.10 21:04:17 5: Video_Doorbell: HandleSendQueue called, qlen = 1
2018.12.10 21:04:17 4: Video_Doorbell: HandleSendQueue sends request type get01 to URL http://123.456.7.8:5005,
data: ding=dong&dong=ding,
header: POST / HTTP/1.1
User-Agent: curl/7.38.0
Host: 123.456.7.8:5005
Accept: */*
Content-Length: 19
Content-Type: application/x-www-form-urlencoded
timeout 2
2018.12.10 21:04:17 5: HttpUtils url=http://123.456.7.8:5005
2018.12.10 21:04:17 3: Video_Doorbell: Read callback: Error: http://123.456.7.8:5005: malformed or unsupported URL
2018.12.10 21:04:17 4: Video_Doorbell: Read callback: request type was get01 retry 0, body empty
2018.12.10 21:04:17 5: Video_Doorbell: ExtractSid called, context get, num 01
2018.12.10 21:04:17 4: Video_Doorbell: CheckAuth decided no authentication required

Zusätzlich habe ich auch set Video_Doorbell klingel2homekitset getestet. Funktioniert auch nicht.

attr Video_Doorbell set01Name klingel2homekitset
attr Video_Doorbell set01URL http://123.456.7.8:5005
attr Video_Doorbell set01Data ding=dong&dong=ding
attr Video_Doorbell set01Header01 POST / HTTP/1.1
attr Video_Doorbell set01Header02 User-Agent: curl/7.38.0
attr Video_Doorbell set01Header03 Host: 123.456.7.8:5005
attr Video_Doorbell set01Header04 Accept: */*
attr Video_Doorbell set01Header05 Content-Length: 19
attr Video_Doorbell set01Header06 Content-Type: application/x-www-form-urlencoded
attr Video_Doorbell set01NoArg 1


Und mit verbose 5 steht im log:
2018.12.10 21:10:17 5: Video_Doorbell: set called with klingel2homekitset
2018.12.10 21:10:17 5: Video_Doorbell: set found option klingel2homekitset in attribute set01Name
2018.12.10 21:10:17 4: Video_Doorbell: set will now set klingel2homekitset
2018.12.10 21:10:17 4: Video_Doorbell: AddToQueue adds set01, initial queue len: 0
2018.12.10 21:10:17 5: Video_Doorbell: AddToQueue adds type set01 to URL http://123.456.7.8:5005, data ding=dong&dong=ding, header POST / HTTP/1.1
User-Agent: curl/7.38.0
Host: 123.456.7.8:5005
Accept: */*
Content-Length: 19
Content-Type: application/x-www-form-urlencoded, retry 0
2018.12.10 21:10:17 5: Video_Doorbell: HandleSendQueue called, qlen = 1
2018.12.10 21:10:17 4: Video_Doorbell: HandleSendQueue sends request type set01 to URL http://123.456.7.8:5005,
data: ding=dong&dong=ding,
header: POST / HTTP/1.1
User-Agent: curl/7.38.0
Host: 123.456.7.8:5005
Accept: */*
Content-Length: 19
Content-Type: application/x-www-form-urlencoded
timeout 2
2018.12.10 21:10:17 5: HttpUtils url=http://123.456.7.8:5005
2018.12.10 21:10:17 3: Video_Doorbell: Read callback: Error: http://123.456.7.8:5005: malformed or unsupported URL
2018.12.10 21:10:17 4: Video_Doorbell: Read callback: request type was set01 retry 0, body empty
2018.12.10 21:10:17 5: Video_Doorbell: ExtractSid called, context set, num 01
2018.12.10 21:10:17 4: Video_Doorbell: CheckAuth decided no authentication required

Bin für jeden Hinweis, wo der Fehler sein könnte dankbar.
Gruß Olaf

amenomade

Mach mal Header1, 3 und 5 weg.
Und nimm noch ein / nach dem port 5005 in der URL.
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

osbs

Vielen Dank, funktioniert! Habe es einzeln durchgetestet.
/ ergänzen und header5 löschen sind die beiden entscheidenden Schritte gewesen.
Sowohl set als get funktionieren beide! Problem gelöst, vielen Dank!

Damit ist folgende Konfiguration funktionsfähig:

define Video_Doorbell HTTPMOD none 0
attr Video_Doorbell get01Name klingel2homekitget
attr Video_Doorbell get01URL http://123.456.7.8:5005/
attr Video_Doorbell get01Data ding=dong&dong=ding
attr Video_Doorbell get01Header02 User-Agent: curl/7.38.0
attr Video_Doorbell get01Header04 Accept: */*
attr Video_Doorbell get01Header06 Content-Type: application/x-www-form-urlencoded
attr Video_Doorbell set01Name klingel2homekitset
attr Video_Doorbell set01URL http://123.456.7.8:5005/
attr Video_Doorbell set01Data ding=dong&dong=ding
attr Video_Doorbell set01Header02 User-Agent: curl/7.38.0
attr Video_Doorbell set01Header04 Accept: */*
attr Video_Doorbell set01Header06 Content-Type: application/x-www-form-urlencoded
attr Video_Doorbell set01NoArg 1


Gruß Olaf