FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: LordVoodoo am 03 Oktober 2017, 23:29:19

Titel: HTTPMOD für TuneBlade
Beitrag von: LordVoodoo am 03 Oktober 2017, 23:29:19
Hallo zusammen,

über HTTPMOD habe ich es inzwischen geschafft, den aktuellen Status von TuneBlade auszulesen:


define Tuneblade_Bad HTTPMOD http://<server>:<port>/devices/<deviceID> 5
attr Tuneblade_Bad reading1Name ID
attr Tuneblade_Bad reading1Regex ID":"(.*?)"
attr Tuneblade_Bad reading2Name Name
attr Tuneblade_Bad reading2Regex Name":"(.*?)"
attr Tuneblade_Bad reading3Name Status
attr Tuneblade_Bad reading3Regex Status":"(.*?)"
attr Tuneblade_Bad reading4Name SubStatus
attr Tuneblade_Bad reading4Regex SubStatus":"(.*?)"
attr Tuneblade_Bad reading5Name Volume
attr Tuneblade_Bad reading5Regex Volume":([\d\.]+)


Allerdings gelingt es mir nicht einen Befahl für Connect an TuneBlade zu senden, vermutlich weil es nicht als PUT-Befehl abgesetzt wird.
Folgendes habe ich konfiguriert:

attr Tuneblade_Bad set01Data {"Status": "$val"}
attr Tuneblade_Bad set01Hint Connect,Disconnect
attr Tuneblade_Bad set01Name Status
attr Tuneblade_Bad set01TextArg 1
attr Tuneblade_Bad set01URL http://<server>:<port>/devices/<deviceID>
attr Tuneblade_Bad setHeader1 Content-Type: application/json


Habe ich einen grundsätzlichen Denkfehler darin?
Die API von TuneBlade liegt unter: http://www.tuneblade.com/developer/TuneBlade%20Remote%20API%20v0.8.pdf

Danke für Eure Hilfe!
Titel: Antw:HTTPMOD für TuneBlade
Beitrag von: amenomade am 04 Oktober 2017, 00:15:16
Was sagt die Log mit verbose 5 ?
Und was sagt die Log vom Device, wie im API beschrieben:
Get errors/logs for a single device
ZitatHTTP Method GET
URI /devices/{ID of the desired device}/log

PS: deine Readings könntest Du auch mit reading[0-9]JSON lesen, statt Regex
Titel: Antw:HTTPMOD für TuneBlade
Beitrag von: amenomade am 04 Oktober 2017, 00:27:25
Es gibt auch eine wichtige Info in der API Ref:
ZitatMisc. Information
Request Headers
All "PUT" requests to the web service must have the following headers set:

Header
Value
Content
-
Type
Application/json
Content
-
Length
<length of JSON>
Titel: Antw:HTTPMOD für TuneBlade
Beitrag von: LordVoodoo am 04 Oktober 2017, 23:10:13
Guten Abend,

auf Verbose-Level 5 wird im Log nicht mehr geschrieben als:
2017-10-04 23:07:07 HTTPMOD Tuneblade_Bad Status Connect

Im Log von TuneBlade war kein Hinweis auf eine empfangene Nachricht, vermutlich wird diese gar nicht aus FHEM abgesetzt.

Wie kann ich dies nachprüfen? Gibt es ein Beispiel im Forum?

Vielen Dank.
Titel: Antw:HTTPMOD für TuneBlade
Beitrag von: amenomade am 05 Oktober 2017, 09:50:17
Zitat von: LordVoodoo am 04 Oktober 2017, 23:10:13
auf Verbose-Level 5 wird im Log nicht mehr geschrieben als:
2017-10-04 23:07:07 HTTPMOD Tuneblade_Bad Status Connect

Kann nicht sein. Attr verbose 5 auf dem HTTPMOD setzen, und dann in der Logfile (nicht im Event Monitor) schauen.

Die Log vom TuneBlade kannst Du einfach aus einem Browser auslesen, vermutlich mit:
http://<server>:<port>/devices/<deviceID>/log
Titel: Antw:HTTPMOD für TuneBlade
Beitrag von: LordVoodoo am 05 Oktober 2017, 19:11:39
Hallo,

inzwischen konnte ich den Log ermitteln, danke für den Hinweis mit der Datei:


2017.10.05 19:09:09 5: Cmd: >set Tuneblade_Bad Status Connect<
2017.10.05 19:09:09 5: Tuneblade_Bad: set called with Status Connect
2017.10.05 19:09:09 5: Tuneblade_Bad: set found option Status in attribute set01Name
2017.10.05 19:09:09 4: Tuneblade_Bad: set will now set Status -> Connect
2017.10.05 19:09:09 4: Tuneblade_Bad: AddToQueue adds set01, initial queue len: 0
2017.10.05 19:09:09 5: Tuneblade_Bad: AddToQueue adds type set01 to URL http://server-nsu:61689/devices/5072246AAE8D@Bad, data {"Status": "$val"}, header Content-Type: application/json, retry 0
2017.10.05 19:09:09 5: Tuneblade_Bad: HandleSendQueue called, qlen = 1
2017.10.05 19:09:09 4: Tuneblade_Bad: HandleSendQueue sends request type set01 to URL http://server-nsu:61689/devices/5072246AAE8D@Bad,
data: {"Status": "Connect"},
header: Content-Type: application/json,
timeout 2
2017.10.05 19:09:09 4: HttpUtils url=http://server-nsu:61689/devices/5072246AAE8D@Bad
2017.10.05 19:09:09 5: IP: server-nsu -> 172.16.0.80
2017.10.05 19:09:09 5: Starting notify loop for Tuneblade_Bad, 1 event(s), first is Status Connect
2017.10.05 19:09:09 5: Tuneblade_Bad: UpdateHintList called
2017.10.05 19:09:09 5: Tuneblade_Bad: UpdateHintList: setlist = Status:Connect,Disconnect
2017.10.05 19:09:09 5: Tuneblade_Bad: UpdateHintList: getlist =
2017.10.05 19:09:09 5: End notify loop for Tuneblade_Bad
2017.10.05 19:09:09 4: WEB: /fhem?cmd.setTuneblade_Bad%3Dset%20Tuneblade_Bad%20Status%20Connect&XHR=1&fwcsrf=csrf_104253407012642&fw_id=7733 / RL:20 / text/plain; charset=UTF-8 / Content-Encoding: gzip
/
2017.10.05 19:09:09 5: HttpUtils request header:
POST /devices/5072246AAE8D@Bad HTTP/1.0
Host: server-nsu:61689
User-Agent: fhem
Content-Type: application/json
Content-Length: 21

2017.10.05 19:09:09 4: http://server-nsu:61689/devices/5072246AAE8D@Bad: HTTP response code 400
2017.10.05 19:09:09 4: HttpUtils http://server-nsu:61689/devices/5072246AAE8D@Bad: Got data, length: 8
2017.10.05 19:09:09 5: HttpUtils response header:
HTTP/1 400 Bad Request
Content-Length: 8
Content-Type: text/plain
2017.10.05 19:09:09 4: Tuneblade_Bad: Read callback: request type was set01 retry 0,
Header: HTTP/1 400 Bad Request
Content-Length: 8
Content-Type: text/plain,
Body: Unknown.
2017.10.05 19:09:09 5: Tuneblade_Bad: ExtractSid called, context set, num 01
2017.10.05 19:09:09 4: Tuneblade_Bad: CheckAuth decided no authentication required
Titel: Antw:HTTPMOD für TuneBlade
Beitrag von: amenomade am 05 Oktober 2017, 20:12:14
Du kriegst HTTP 400 als Antwort
HTTP/1 400 Bad Request
Hängt wahrscheinlich an was ich oben geschrieben habe:
ZitatAll "PUT" requests to the web service must have the following headers set: usw...