Senden von JSON per PUT mit HTTPMOD

Begonnen von Thyrador, 08 Juni 2023, 22:50:38

Vorheriges Thema - Nächstes Thema

Thyrador

Moin.

Ich hab folgendes Device:
defmod Elgato.STD.RingLight HTTPMOD none 0
attr Elgato.STD.RingLight group Scene3
attr Elgato.STD.RingLight room Studio
attr Elgato.STD.RingLight set01Data {"numberOfLights":1,"lights":[{"on":$val,"brightness":100,"temperature":344}]}
attr Elgato.STD.RingLight set01Header1 Content-type:application/json, Accept:application/json, Connection:keep-alive
attr Elgato.STD.RingLight set01Hint 0,1
attr Elgato.STD.RingLight set01Method PUT
attr Elgato.STD.RingLight set01Name On
attr Elgato.STD.RingLight set01URL http://*.*.*.*:9123/elgato/lights
attr Elgato.STD.RingLight verbose 5

Versuche ich nun On auf 0 oder 1 zu setzen, erhalte ich im Log nur folgenden Abschnitt, eine Schaltung jedoch erfolgt nicht (da 400 Fehler):
2023.06.08 22:30:18 5: Elgato.STD.RingLight: set called with On
2023.06.08 22:30:18 5: Elgato.STD.RingLight: set found option On in attribute set01Name
2023.06.08 22:30:18 1: PERL WARNING: Use of uninitialized value $type in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 805.
2023.06.08 22:30:18 1: PERL WARNING: Use of uninitialized value $type in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 812.
2023.06.08 22:30:18 4: Elgato.STD.RingLight: set will now set On -> 0
2023.06.08 22:30:18 5: Elgato.STD.RingLight: AddToQueue adds type set01 to URL http://*.*.*.*:9123/elgato/lights, data {"numberOfLights":1,"lights":[{"on":$val,"brightness":100,"temperature":344}]}, header Content-type:application/json, Accept:application/json, Connection:keep-alive, retry 0, initial queue len: 0
2023.06.08 22:30:18 5: Elgato.STD.RingLight: HandleSendQueue called from AddToSendQueue, qlen = 1
2023.06.08 22:30:18 5: Elgato.STD.RingLight: HandleSendQueue - call with HTTP METHOD: PUT
2023.06.08 22:30:18 4: Elgato.STD.RingLight: HandleSendQueue sends set01 with timeout 2 to http://*.*.*.*:9123/elgato/lights,
data: {"numberOfLights":1,"lights":[{"on":0,"brightness":100,"temperature":344}]},
header: Content-type:application/json, Accept:application/json, Connection:keep-alive
2023.06.08 22:30:18 5: Elgato.STD.RingLight: ReadCallback called from __ANON__
2023.06.08 22:30:18 4: Elgato.STD.RingLight: Read callback: request type was set01 retry 0,
header: HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8
Content-Length: 0
Connection: keep-alive, no body
2023.06.08 22:30:18 5: Elgato.STD.RingLight: Read callback: body empty
2023.06.08 22:30:18 4: Elgato.STD.RingLight: BodyDecode is not decoding the response body (charset utf-8, bodyDecode defaults to none)
2023.06.08 22:30:18 5: Elgato.STD.RingLight: GetCookies is looking for Cookies
2023.06.08 22:30:18 5: Elgato.STD.RingLight: ExtractSid called, context set, num 01
2023.06.08 22:30:18 4: Elgato.STD.RingLight: checking for redirects, code=400, ignore=0
2023.06.08 22:30:18 4: Elgato.STD.RingLight: no redirects to handle
2023.06.08 22:30:18 5: Elgato.STD.RingLight: Read callback sets LAST_REQUEST to set01
2023.06.08 22:30:18 5: Elgato.STD.RingLight: CheckAuth decided no authentication required

Rufe ich den Befehl per curl, Postman oder Tasker (ich wollte halt sicher gehen, dass es nicht an der Abfrage selbst liegt), klappt das Ganze ohne Probleme:
curl -X PUT http://*.*.*.*:9123/elgato/lights \
   -H 'Content-type:application/json, Accept:application/json, Connection:keep-alive' \
   -d '{"numberOfLights":1,"lights":[{"on":1,"brightness":100,"temperature":344}]}'
Übersehe ich hier etwas?

Ich bin hier irgendwie mit meinem Latein am Ende. Hat jemand eine Idee, was notwendig ist, damit ich es zum Laufen bekomme?

StefanStrobel

Hallo,

curl sendet per Default HTTP/1.1. HTTPMOD 1.0.
probier doch mal das Attribut httpVersion mit 1.1

Gruss
   Stefan

Thyrador

Zitat von: StefanStrobel am 13 Juni 2023, 19:16:03Hallo,

curl sendet per Default HTTP/1.1. HTTPMOD 1.0.
probier doch mal das Attribut httpVersion mit 1.1

Gruss
   Stefan

HA! Das war's. Mehr war tatsächlich gar nicht notwendig. Ich kann dir gar nicht genug dafür danken.

Oder um es in den Worten eines altbekannten Sachsen treffend zu formulieren: "SO NE SCHEI*E DER GEHT! ICH RESCHE MICH OFF Ä WOCHENENDE UND DER GEHT!" ;D

Aber im Ernst, vielen lieben Dank!