Miele 3rd party API in FHEM einbinden

Begonnen von xerion, 16 Januar 2019, 22:26:52

Vorheriges Thema - Nächstes Thema

xerion

Hallo liebe FHEM-Gemeinde,

ich bin noch ziemlich frisch in der FHEM Welt unterwegs, konnte mir aber dank euch schon viele nützliche Features implementieren. Da ich leider kein Programmier bin, bin ich umso dankbarer das es dieses Forum gibt. Viele Anfänger Probleme konnte ich mit dem Forum lösen aber bei einer Implementierung komme ich einfach nicht weiter. Das Projekt, was ich vorhabe ist, sobald meine PV-Anlage entsprechend Überstrom produziert, dass die Waschmaschine eingeschaltet wird. Ich habe einen Speicher von SENEC und habe über HTTPMOD auch schon die Möglichkeit gefunden den Befehl zu bekommen. Nun möchte ich aber diesen Befehl nutzen um die Waschmaschine zu einzuschalten. Seit kurzen ist es möglich, dass man über die Miele API (https://www.miele.com/developer/swagger-ui/index.html#/) auch PUT Befehle senden kann. Über das Tool Postman konnte ich auch schon erfolgreich die API ansprechen und die Waschmaschine auslesen und fernsteuern. Zusätzlich habe ich die Kommunikation mit Burp Suite abgefangen. Es gibt zwar im Netz schon unterschiedliche PHP Skripte, aber entweder funktionieren die nicht mehr wegen geänderten Loginverfahren, oder sind speziell für andere System geschrieben oder können die PUT Befehl noch nicht umsetzen. Daher möchte ich es unabhängig von anderen Skripten, direkt in FHEM umsetzen, sofern das möglich ist.

Hier der Burp Auszug vom GET Befehl:
GET /v1/devices/?language=de HTTP/1.1
cache-control: no-cache
Postman-Token: xxxxxxxxxxxxxxxxxxxxxxxx
Authorization: Bearer DE_xxxxxxxxxxxxxxxxxxxxx
User-Agent: PostmanRuntime/7.6.0
Accept: */*
Host: api.mcs3.miele.com
Accept-Encoding: gzip, deflate
Connection: close


Hier der Burp Auszug vom PUT Befehl:
PUT /v1/devices/000149130299/actions HTTP/1.1
Content-Type: application/json
cache-control: no-cache
Postman-Token: xxxxxxxxxxxxxxxxxxx
Authorization: Bearer DE_xxxxxxxxxxxxxxxxxxxx
User-Agent: PostmanRuntime/7.6.0
Accept: */*
Host: api.mcs3.miele.com
Accept-Encoding: gzip, deflate
Content-Length: 19
Connection: close

{"processAction":1}


PS: Die Tokens wurden unkenntlich gemacht


Da die API aber OAUTH2 Authentifizierung nutzt, habe ich leider nichts passendes im Forum gefunden was ich für die Umsetzung nutzen kann. Meine erste Idee war, es über HTTPMOD umzusetzen. Dort bekomme ich aber immer wieder den Fehler {"code":415,"message":"HTTP 415 Unsupported Media Type"}

defmod Miele_API HTTPMOD https://api.mcs3.miele.com 60
attr Miele_API userattr get01Name get01Poll:0,1 get01URL getHeader1 requestHeader1
attr Miele_API enableControlSet 1
attr Miele_API get01Name data
attr Miele_API get01Poll 1
attr Miele_API get01URL https://api.mcs3.miele.com/v1/devices/?language=de
attr Miele_API getHeader1 Authorization: Bearer DE_xxxxxxxxxxxxxxxxx
attr Miele_API httpVersion 1.1
attr Miele_API reading01RegOpt s
attr Miele_API reading01Regex ^(.*)$
attr Miele_API requestHeader1 Authorization: Bearer DE_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
attr Miele_API room Waschmaschine
attr Miele_API verbose 5

setstate Miele_API 2019-01-16 21:47:35 reading01 HTTP/1.1 415 Unsupported Media Type
\
Date: Wed, 16 Jan 2019 20:47:35 GMT
\
Content-Type: application/json
\
Content-Length: 56
\
Connection: close
\
Access-Control-Allow-Origin: *
\
Access-Control-Allow-Credentials: true
\
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS
\
Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization
\
Strict-Transport-Security: max-age=15724800;; includeSubDomains
\

\
{"code":415,"message":"HTTP 415 Unsupported Media Type"}


Ich scheitere schon daran nur die Abfrage vom Status hinzubekommen, und mit der Authentifizierung bzw, Refresh Token habe ich mich noch nicht mal befasst, da der Token erstmal eine Gültigkeit von 30 Tagen hat. ;-)
Ich hoffe das mir jemand helfen kann und die Informationen für den Anfang ausreichen.
Ich denke das es mehrere Leute gibt die gerne die API von Miele über FHEM ansteuern möchten.
Ich würde mich  freuen, wenn du meinen Einladungscode für Tibber, der Stromanbieter, der dir hilft, deinen Stromverbrauch zu verstehen und zu reduzieren, nutzt: https://invite.tibber.com/5fc08jbs. So bekommen wir beide 50 Euro und 100 % Ökostrom / https://geld-fuer-eauto.de/ref/334561880

amenomade

ZitatHTTP 415 Unsupported Media Type
Setz mal ein Header mit Content-Type: application/json
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

amenomade

Und attr enableCookies könnte für oauth2 helfen.
Wenn es nicht reicht, dann bite ein vollständiges "list" des HTTPMOD Devices und Log Auszug mit verbose 5 bitte (natürlich anonymsiert)
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

xerion

Hallo amenomade, danke für deine schnelle Rückmeldung. Leider haben die beiden Settings keine Verbesserung gebracht.

Hier der Auszug von "list":
Internals:
   BUSY       0
   DEF        https://api.mcs3.miele.com 60
   Interval   60
   LASTSEND   1547752867.82202
   MainURL    https://api.mcs3.miele.com
   ModuleVersion 3.5.4 - 9.11.2018
   NAME       Miele_API
   NR         78
   STATE      ???
   TRIGGERTIME 1547752926.80505
   TRIGGERTIME_FMT 2019-01-17 20:22:06
   TYPE       HTTPMOD
   addr       https://api.mcs3.miele.com:443
   auth       0
   buf       
   code       415
   compress   1
   conn       
   data       
   displayurl https://api.mcs3.miele.com/v1/devices/?language=de
   header     Authorization: Bearer DE_??????????????????????????ßß
   host       api.mcs3.miele.com
   httpheader HTTP/1.1 415 Unsupported Media Type
Date: Thu, 17 Jan 2019 19:21:07 GMT
Content-Type: application/json
Content-Length: 56
Connection: close
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS
Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization
Strict-Transport-Security: max-age=15724800; includeSubDomains
   httpversion 1.1
   hu_blocking 0
   hu_filecount 864
   hu_port    443
   hu_portSfx
   ignoreredirects 0
   loglevel   4
   path       /v1/devices/?language=de
   protocol   https
   redirects  0
   timeout    2
   url        https://api.mcs3.miele.com/v1/devices/?language=de
   value      0
   QUEUE:
   READINGS:
     2019-01-17 20:21:07   reading01       HTTP/1.1 415 Unsupported Media Type
Date: Thu, 17 Jan 2019 19:21:07 GMT
Content-Type: application/json
Content-Length: 56
Connection: close
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS
Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization
Strict-Transport-Security: max-age=15724800; includeSubDomains

{"code":415,"message":"HTTP 415 Unsupported Media Type"}
   REQUEST:
     data       
     header     Authorization: Bearer DE_?????????????????????????
     ignoreredirects 0
     retryCount 0
     type       get01
     url        https://api.mcs3.miele.com/v1/devices/?language=de
     value      0
   defptr:
     readingBase:
       reading01  reading
     readingNum:
       reading01  01
     readingOutdated:
     requestReadings:
       get01:
         reading01  reading 01
   lastpoll:
     data       1547752866.80353
   sslargs:
Attributes:
   enableControlSet 1
   enableCookies 1
   get01Name  data
   get01Poll  1
   get01URL   https://api.mcs3.miele.com/v1/devices/?language=de
   getHeader1 Authorization: Bearer DE_???????????????????????????????????
   httpVersion 1.1
   reading01RegOpt s
   reading01Regex ^(.*)$
   requestHeader1 Authorization: Bearer DE_???????????????????????????????
   requestHeader2 Content-Type: application/json
   room       Waschmaschine
   userattr   get01Name get01Poll:0,1 get01URL getHeader1 reading01RegOpt reading01Regex requestHeader1 requestHeader2
   verbose    5


und vom Logfile:2019.01.17 20:27:05 5 : Miele_API: get called with data
2019.01.17 20:27:05 5 : Miele_API: get found option data in attribute get01Name
2019.01.17 20:27:05 4 : Miele_API: get will now request data, no optional value
2019.01.17 20:27:05 4 : Miele_API: AddToQueue adds get01, initial queue len: 0
2019.01.17 20:27:05 5 : Miele_API: AddToQueue adds type get01 to URL https://api.mcs3.miele.com/v1/devices/?language=de, no data, header Authorization: Bearer DE_???????????????????????????????????, retry 0
2019.01.17 20:27:05 5 : Miele_API: HandleSendQueue called, qlen = 1
2019.01.17 20:27:05 4 : Miele_API: HandleSendQueue sends request type get01 to URL https://api.mcs3.miele.com/v1/devices/?language=de, No Data, header: Authorization: Bearer DE_??????????????????????????????????? timeout 2
2019.01.17 20:27:05 5 : HttpUtils url=https://api.mcs3.miele.com/v1/devices/?language=de
2019.01.17 20:27:05 4 : IP: api.mcs3.miele.com -> 157.97.106.171
2019.01.17 20:27:05 5 : HttpUtils request header: GET /v1/devices/?language=de HTTP/1.1 Host: api.mcs3.miele.com User-Agent: fhem Accept-Encoding: gzip,deflate Connection: Close Authorization: Bearer DE_??????????????????????????????????? Content-Length: 0 Content-Type: application/x-www-form-urlencoded
2019.01.17 20:27:05 4 : https://api.mcs3.miele.com/v1/devices/?language=de: HTTP response code 415
2019.01.17 20:27:05 5 : HttpUtils https://api.mcs3.miele.com/v1/devices/?language=de: Got data, length: 56
2019.01.17 20:27:05 5 : HttpUtils response header: HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 19:27:05 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains
2019.01.17 20:27:05 4 : Miele_API: Read callback: request type was get01 retry 0, Body: {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 20:27:05 5 : Miele_API: GetCookies is looking for Cookies
2019.01.17 20:27:05 5 : Miele_API: ExtractSid called, context get, num 01
2019.01.17 20:27:05 4 : Miele_API: CheckAuth decided no authentication required
2019.01.17 20:27:05 5 : Miele_API: ExtractReading for context get, num 01 - no individual parse definition
2019.01.17 20:27:05 5 : Miele_API: Read starts parsing response to get01 with defined readings: 01
2019.01.17 20:27:05 5 : Miele_API: ExtractReading reading01 with regex /^(.*)$/s ...
2019.01.17 20:27:05 5 : Miele_API: 1 capture group(s), matchlist = HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 19:27:05 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 20:27:05 4 : Miele_API: ExtractReading for reading01-1 sets reading01 to HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 19:27:05 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 20:27:05 4 : Miele_API: Read response to get01 matched Reading(s) reading01
2019-01-17 20:27:05 HTTPMOD Miele_API reading01: HTTP/1.1 415 Unsupported Media Type  Date: Thu, 17 Jan 2019 19:27:05 GMT  Content-Type: application/json  Content-Length: 56  Connection: close  Access-Control-Allow-Origin: *  Access-Control-Allow-Credentials: true  Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS  Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization  Strict-Transport-Security: max-age=15724800; includeSubDomains    {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 20:27:05 5 : Miele_API: HandleSendQueue called, qlen = 0
2019.01.17 20:27:06 4 : Miele_API: GetUpdate called (update)
2019.01.17 20:27:06 4 : Miele_API: update timer modified: will call GetUpdate in 60.0 seconds at 2019-01-17 20:28:06
2019.01.17 20:27:06 4 : Miele_API: AddToQueue adds update, initial queue len: 0
2019.01.17 20:27:06 5 : Miele_API: AddToQueue adds type update to URL https://api.mcs3.miele.com, no data, header Authorization: Bearer DE_??????????????????????????????????? Content-Type: application/json, retry 0
2019.01.17 20:27:06 5 : Miele_API: HandleSendQueue called, qlen = 1
2019.01.17 20:27:06 4 : Miele_API: HandleSendQueue sends request type update to URL https://api.mcs3.miele.com, No Data, header: Authorization: Bearer DE_??????????????????????????????????? Content-Type: application/json timeout 2
2019.01.17 20:27:06 5 : HttpUtils url=https://api.mcs3.miele.com
2019.01.17 20:27:06 3 : Miele_API: Read callback: Error: https://api.mcs3.miele.com: malformed or unsupported URL
2019.01.17 20:27:06 4 : Miele_API: Read callback: request type was update retry 0, body empty
2019.01.17 20:27:06 5 : Miele_API: GetCookies is looking for Cookies
2019.01.17 20:27:06 5 : Miele_API: ExtractSid called, context reading, num
2019.01.17 20:27:06 4 : Miele_API: CheckAuth decided no authentication required
2019.01.17 20:27:06 5 : Miele_API: GetUpdate checks if poll required for data (01)
2019.01.17 20:27:06 4 : Miele_API: GetUpdate will request data
2019.01.17 20:27:06 4 : Miele_API: AddToQueue adds get01, initial queue len: 0
2019.01.17 20:27:06 5 : Miele_API: AddToQueue adds type get01 to URL https://api.mcs3.miele.com/v1/devices/?language=de, no data, header Authorization: Bearer DE_???????????????????????????????????, retry 0
2019.01.17 20:27:06 5 : Miele_API: HandleSendQueue called, qlen = 1
2019.01.17 20:27:06 5 : Miele_API: HandleSendQueue - minSendDelay not over, rescheduling
2019.01.17 20:27:07 5 : Miele_API: HandleSendQueue called, qlen = 1
2019.01.17 20:27:07 4 : Miele_API: HandleSendQueue sends request type get01 to URL https://api.mcs3.miele.com/v1/devices/?language=de, No Data, header: Authorization: Bearer DE_??????????????????????????????????? timeout 2
2019.01.17 20:27:07 5 : HttpUtils url=https://api.mcs3.miele.com/v1/devices/?language=de
2019.01.17 20:27:07 4 : IP: api.mcs3.miele.com -> 157.97.106.171
2019.01.17 20:27:07 5 : HttpUtils request header: GET /v1/devices/?language=de HTTP/1.1 Host: api.mcs3.miele.com User-Agent: fhem Accept-Encoding: gzip,deflate Connection: Close Authorization: Bearer DE_??????????????????????????????????? Content-Length: 0 Content-Type: application/x-www-form-urlencoded
2019.01.17 20:27:07 4 : https://api.mcs3.miele.com/v1/devices/?language=de: HTTP response code 415
2019.01.17 20:27:07 5 : HttpUtils https://api.mcs3.miele.com/v1/devices/?language=de: Got data, length: 56
2019.01.17 20:27:07 5 : HttpUtils response header: HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 19:27:07 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains
2019.01.17 20:27:07 4 : Miele_API: Read callback: request type was get01 retry 0, Body: {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 20:27:08 5 : Miele_API: GetCookies is looking for Cookies
2019.01.17 20:27:08 5 : Miele_API: ExtractSid called, context get, num 01
2019.01.17 20:27:08 4 : Miele_API: CheckAuth decided no authentication required
2019.01.17 20:27:08 5 : Miele_API: ExtractReading for context get, num 01 - no individual parse definition
2019.01.17 20:27:08 5 : Miele_API: Read starts parsing response to get01 with defined readings: 01
2019.01.17 20:27:08 5 : Miele_API: ExtractReading reading01 with regex /^(.*)$/s ...
2019.01.17 20:27:08 5 : Miele_API: 1 capture group(s), matchlist = HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 19:27:07 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 20:27:08 4 : Miele_API: ExtractReading for reading01-1 sets reading01 to HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 19:27:07 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 20:27:08 4 : Miele_API: Read response to get01 matched Reading(s) reading01
2019-01-17 20:27:08 HTTPMOD Miele_API reading01: HTTP/1.1 415 Unsupported Media Type  Date: Thu, 17 Jan 2019 19:27:07 GMT  Content-Type: application/json  Content-Length: 56  Connection: close  Access-Control-Allow-Origin: *  Access-Control-Allow-Credentials: true  Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS  Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization  Strict-Transport-Security: max-age=15724800; includeSubDomains    {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 20:27:08 5 : Miele_API: HandleSendQueue called, qlen = 0

Ich würde mich  freuen, wenn du meinen Einladungscode für Tibber, der Stromanbieter, der dir hilft, deinen Stromverbrauch zu verstehen und zu reduzieren, nutzt: https://invite.tibber.com/5fc08jbs. So bekommen wir beide 50 Euro und 100 % Ökostrom / https://geld-fuer-eauto.de/ref/334561880

amenomade

Die Antwort 415 kommt von get01, nicht von der haupt Request.

Probier mal mit einem zusätzlichen HeadergetHeader2 accept: application/json; charset=utf-8
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

xerion

Ich würde mich  freuen, wenn du meinen Einladungscode für Tibber, der Stromanbieter, der dir hilft, deinen Stromverbrauch zu verstehen und zu reduzieren, nutzt: https://invite.tibber.com/5fc08jbs. So bekommen wir beide 50 Euro und 100 % Ökostrom / https://geld-fuer-eauto.de/ref/334561880

amenomade

Ein Stück Log wäre nicht schlecht...
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

xerion

Sorry.
2019.01.17 21:05:06 5 : Miele_API: get called with data
2019.01.17 21:05:06 5 : Miele_API: get found option data in attribute get01Name
2019.01.17 21:05:06 4 : Miele_API: get will now request data, no optional value
2019.01.17 21:05:06 4 : Miele_API: AddToQueue adds get01, initial queue len: 0
2019.01.17 21:05:06 5 : Miele_API: AddToQueue adds type get01 to URL https://api.mcs3.miele.com/v1/devices/?language=de, no data, header Authorization: Bearer DE_??????????????????????????????????? accept: application/json; charset=utf-8, retry 0
2019.01.17 21:05:06 5 : Miele_API: HandleSendQueue called, qlen = 1
2019.01.17 21:05:06 4 : Miele_API: HandleSendQueue sends request type get01 to URL https://api.mcs3.miele.com/v1/devices/?language=de, No Data, header: Authorization: Bearer DE_??????????????????????????????????? accept: application/json; charset=utf-8 timeout 2
2019.01.17 21:05:06 5 : HttpUtils url=https://api.mcs3.miele.com/v1/devices/?language=de
2019.01.17 21:05:06 4 : IP: api.mcs3.miele.com -> 157.97.106.171
2019.01.17 21:05:06 5 : HttpUtils request header: GET /v1/devices/?language=de HTTP/1.1 Host: api.mcs3.miele.com User-Agent: fhem Accept-Encoding: gzip,deflate Connection: Close Authorization: Bearer DE_??????????????????????????????????? accept: application/json; charset=utf-8 Content-Length: 0 Content-Type: application/x-www-form-urlencoded
2019.01.17 21:05:06 4 : https://api.mcs3.miele.com/v1/devices/?language=de: HTTP response code 415
2019.01.17 21:05:06 5 : HttpUtils https://api.mcs3.miele.com/v1/devices/?language=de: Got data, length: 56
2019.01.17 21:05:06 5 : HttpUtils response header: HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 20:05:06 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains
2019.01.17 21:05:06 4 : Miele_API: Read callback: request type was get01 retry 0, Body: {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:05:06 5 : Miele_API: GetCookies is looking for Cookies
2019.01.17 21:05:06 5 : Miele_API: ExtractSid called, context get, num 01
2019.01.17 21:05:06 4 : Miele_API: CheckAuth decided no authentication required
2019.01.17 21:05:06 5 : Miele_API: ExtractReading for context get, num 01 - no individual parse definition
2019.01.17 21:05:06 5 : Miele_API: Read starts parsing response to get01 with defined readings: 01
2019.01.17 21:05:06 5 : Miele_API: ExtractReading reading01 with regex /^(.*)$/s ...
2019.01.17 21:05:06 5 : Miele_API: 1 capture group(s), matchlist = HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 20:05:06 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:05:06 4 : Miele_API: ExtractReading for reading01-1 sets reading01 to HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 20:05:06 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:05:06 4 : Miele_API: Read response to get01 matched Reading(s) reading01
2019-01-17 21:05:06 HTTPMOD Miele_API reading01: HTTP/1.1 415 Unsupported Media Type  Date: Thu, 17 Jan 2019 20:05:06 GMT  Content-Type: application/json  Content-Length: 56  Connection: close  Access-Control-Allow-Origin: *  Access-Control-Allow-Credentials: true  Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS  Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization  Strict-Transport-Security: max-age=15724800; includeSubDomains    {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:05:06 5 : Miele_API: HandleSendQueue called, qlen = 0
2019.01.17 21:05:11 4 : Miele_API: GetUpdate called (update)
2019.01.17 21:05:11 4 : Miele_API: update timer modified: will call GetUpdate in 60.0 seconds at 2019-01-17 21:06:11
2019.01.17 21:05:11 4 : Miele_API: AddToQueue adds update, initial queue len: 0
2019.01.17 21:05:11 5 : Miele_API: AddToQueue adds type update to URL https://api.mcs3.miele.com, no data, header Authorization: Bearer DE_??????????????????????????????????? Content-Type: application/json, retry 0
2019.01.17 21:05:11 5 : Miele_API: HandleSendQueue called, qlen = 1
2019.01.17 21:05:11 4 : Miele_API: HandleSendQueue sends request type update to URL https://api.mcs3.miele.com, No Data, header: Authorization: Bearer DE_??????????????????????????????????? Content-Type: application/json timeout 2
2019.01.17 21:05:11 5 : HttpUtils url=https://api.mcs3.miele.com
2019.01.17 21:05:11 3 : Miele_API: Read callback: Error: https://api.mcs3.miele.com: malformed or unsupported URL
2019.01.17 21:05:11 4 : Miele_API: Read callback: request type was update retry 0, body empty
2019.01.17 21:05:11 5 : Miele_API: GetCookies is looking for Cookies
2019.01.17 21:05:11 5 : Miele_API: ExtractSid called, context reading, num
2019.01.17 21:05:11 4 : Miele_API: CheckAuth decided no authentication required
2019.01.17 21:05:11 5 : Miele_API: GetUpdate checks if poll required for data (01)
2019.01.17 21:05:11 4 : Miele_API: GetUpdate will request data
2019.01.17 21:05:11 4 : Miele_API: AddToQueue adds get01, initial queue len: 0
2019.01.17 21:05:11 5 : Miele_API: AddToQueue adds type get01 to URL https://api.mcs3.miele.com/v1/devices/?language=de, no data, header Authorization: Bearer DE_??????????????????????????????????? accept: application/json; charset=utf-8, retry 0
2019.01.17 21:05:11 5 : Miele_API: HandleSendQueue called, qlen = 1
2019.01.17 21:05:11 5 : Miele_API: HandleSendQueue - minSendDelay not over, rescheduling
2019.01.17 21:05:12 5 : Miele_API: HandleSendQueue called, qlen = 1
2019.01.17 21:05:12 4 : Miele_API: HandleSendQueue sends request type get01 to URL https://api.mcs3.miele.com/v1/devices/?language=de, No Data, header: Authorization: Bearer DE_??????????????????????????????????? accept: application/json; charset=utf-8 timeout 2
2019.01.17 21:05:12 5 : HttpUtils url=https://api.mcs3.miele.com/v1/devices/?language=de
2019.01.17 21:05:12 4 : IP: api.mcs3.miele.com -> 157.97.106.171
2019.01.17 21:05:12 5 : HttpUtils request header: GET /v1/devices/?language=de HTTP/1.1 Host: api.mcs3.miele.com User-Agent: fhem Accept-Encoding: gzip,deflate Connection: Close Authorization: Bearer DE_??????????????????????????????????? accept: application/json; charset=utf-8 Content-Length: 0 Content-Type: application/x-www-form-urlencoded
2019.01.17 21:05:12 4 : https://api.mcs3.miele.com/v1/devices/?language=de: HTTP response code 415
2019.01.17 21:05:12 5 : HttpUtils https://api.mcs3.miele.com/v1/devices/?language=de: Got data, length: 56
2019.01.17 21:05:12 5 : HttpUtils response header: HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 20:05:12 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains
2019.01.17 21:05:12 4 : Miele_API: Read callback: request type was get01 retry 0, Body: {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:05:12 5 : Miele_API: GetCookies is looking for Cookies
2019.01.17 21:05:12 5 : Miele_API: ExtractSid called, context get, num 01
2019.01.17 21:05:12 4 : Miele_API: CheckAuth decided no authentication required
2019.01.17 21:05:12 5 : Miele_API: ExtractReading for context get, num 01 - no individual parse definition
2019.01.17 21:05:12 5 : Miele_API: Read starts parsing response to get01 with defined readings: 01
2019.01.17 21:05:12 5 : Miele_API: ExtractReading reading01 with regex /^(.*)$/s ...
2019.01.17 21:05:12 5 : Miele_API: 1 capture group(s), matchlist = HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 20:05:12 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:05:12 4 : Miele_API: ExtractReading for reading01-1 sets reading01 to HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 20:05:12 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:05:12 4 : Miele_API: Read response to get01 matched Reading(s) reading01
2019-01-17 21:05:12 HTTPMOD Miele_API reading01: HTTP/1.1 415 Unsupported Media Type  Date: Thu, 17 Jan 2019 20:05:12 GMT  Content-Type: application/json  Content-Length: 56  Connection: close  Access-Control-Allow-Origin: *  Access-Control-Allow-Credentials: true  Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS  Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization  Strict-Transport-Security: max-age=15724800; includeSubDomains    {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:05:12 5 : Miele_API: HandleSendQueue called, qlen = 0
Ich würde mich  freuen, wenn du meinen Einladungscode für Tibber, der Stromanbieter, der dir hilft, deinen Stromverbrauch zu verstehen und zu reduzieren, nutzt: https://invite.tibber.com/5fc08jbs. So bekommen wir beide 50 Euro und 100 % Ökostrom / https://geld-fuer-eauto.de/ref/334561880

amenomade

Es gibt mehrere Probleme.

1 - Ich würde erstmal die haupt Requests deaktivieren defmod Miele_API HTTPMOD https://api.mcs3.miele.com/ 0. Damit sollten die "Read Callbak Error unsupported URL" verschwinden. Die Log wird sauberer, es wird nur das get01 manuell durchgeführt. Besser zu analysieren, da wir dann sicher sind, wofür die Antwort kommt. Ausserdem hat es keinen Sinn, die reine API Url ohne etwas dahinten zu rufen.

2 - Es war mein Schuld: requestHeader2 bitte löschen. Das ist an der Stelle kein application/json.
getHeader2 aber behalten.

...und wieder die Log bitte ;)



Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

xerion

So das nächste Logfile ist übersichtliche geworden:
2019.01.17 21:23:06 5 : Miele_API: get called with data
2019.01.17 21:23:06 5 : Miele_API: get found option data in attribute get01Name
2019.01.17 21:23:06 4 : Miele_API: get will now request data, no optional value
2019.01.17 21:23:06 4 : Miele_API: AddToQueue adds get01, initial queue len: 0
2019.01.17 21:23:06 5 : Miele_API: AddToQueue adds type get01 to URL https://api.mcs3.miele.com/v1/devices/?language=de, no data, header Authorization: Bearer DE_??????????????????????????????????? accept: application/json; charset=utf-8, retry 0
2019.01.17 21:23:06 5 : Miele_API: HandleSendQueue called, qlen = 1
2019.01.17 21:23:06 4 : Miele_API: HandleSendQueue sends request type get01 to URL https://api.mcs3.miele.com/v1/devices/?language=de, No Data, header: Authorization: Bearer DE_??????????????????????????????????? accept: application/json; charset=utf-8 timeout 2
2019.01.17 21:23:06 5 : HttpUtils url=https://api.mcs3.miele.com/v1/devices/?language=de
2019.01.17 21:23:06 4 : IP: api.mcs3.miele.com -> 157.97.106.171
2019.01.17 21:23:06 5 : HttpUtils request header: GET /v1/devices/?language=de HTTP/1.1 Host: api.mcs3.miele.com User-Agent: fhem Accept-Encoding: gzip,deflate Connection: Close Authorization: Bearer DE_??????????????????????????????????? accept: application/json; charset=utf-8 Content-Length: 0 Content-Type: application/x-www-form-urlencoded
2019.01.17 21:23:06 4 : https://api.mcs3.miele.com/v1/devices/?language=de: HTTP response code 415
2019.01.17 21:23:06 5 : HttpUtils https://api.mcs3.miele.com/v1/devices/?language=de: Got data, length: 56
2019.01.17 21:23:06 5 : HttpUtils response header: HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 20:23:06 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains
2019.01.17 21:23:06 4 : Miele_API: Read callback: request type was get01 retry 0, Body: {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:23:06 5 : Miele_API: GetCookies is looking for Cookies
2019.01.17 21:23:06 5 : Miele_API: ExtractSid called, context get, num 01
2019.01.17 21:23:06 4 : Miele_API: CheckAuth decided no authentication required
2019.01.17 21:23:06 5 : Miele_API: ExtractReading for context get, num 01 - no individual parse definition
2019.01.17 21:23:06 5 : Miele_API: Read starts parsing response to get01 with defined readings: 01
2019.01.17 21:23:06 5 : Miele_API: ExtractReading reading01 with regex /^(.*)$/s ...
2019.01.17 21:23:06 5 : Miele_API: 1 capture group(s), matchlist = HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 20:23:06 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:23:06 4 : Miele_API: ExtractReading for reading01-1 sets reading01 to HTTP/1.1 415 Unsupported Media Type Date: Thu, 17 Jan 2019 20:23:06 GMT Content-Type: application/json Content-Length: 56 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Strict-Transport-Security: max-age=15724800; includeSubDomains {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:23:06 4 : Miele_API: Read response to get01 matched Reading(s) reading01
2019-01-17 21:23:06 HTTPMOD Miele_API reading01: HTTP/1.1 415 Unsupported Media Type  Date: Thu, 17 Jan 2019 20:23:06 GMT  Content-Type: application/json  Content-Length: 56  Connection: close  Access-Control-Allow-Origin: *  Access-Control-Allow-Credentials: true  Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS  Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization  Strict-Transport-Security: max-age=15724800; includeSubDomains    {"code":415,"message":"HTTP 415 Unsupported Media Type"}
2019.01.17 21:23:06 5 : Miele_API: HandleSendQueue called, qlen = 0

Ich würde mich  freuen, wenn du meinen Einladungscode für Tibber, der Stromanbieter, der dir hilft, deinen Stromverbrauch zu verstehen und zu reduzieren, nutzt: https://invite.tibber.com/5fc08jbs. So bekommen wir beide 50 Euro und 100 % Ökostrom / https://geld-fuer-eauto.de/ref/334561880

amenomade

Hmm... irgendwie mag er die Headers nicht. Ich vermute insbesondere Content-Length: 0 Content-Type: application/x-www-form-urlencoded

Wie sieht die "Raw" Request in Burp aus?
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

xerion

Wenn ich den request über Postman durchführe (was funktioniert) kommt folgende RAW Information in Burp an:
GET /v1/devices/?language=de HTTP/1.1
cache-control: no-cache
Postman-Token: ????????????????????????????????
Authorization: Bearer DE_?????????????????????????????
User-Agent: PostmanRuntime/7.6.0
Accept: */*
Host: api.mcs3.miele.com
Accept-Encoding: gzip, deflate
Connection: close
Ich würde mich  freuen, wenn du meinen Einladungscode für Tibber, der Stromanbieter, der dir hilft, deinen Stromverbrauch zu verstehen und zu reduzieren, nutzt: https://invite.tibber.com/5fc08jbs. So bekommen wir beide 50 Euro und 100 % Ökostrom / https://geld-fuer-eauto.de/ref/334561880

amenomade

Ja, das Content-type wird von fhem/httputils hinzugefügt, was Postman nicht macht.
Ich kann nicht die verschiedenen Möglichkeiten selbst testen, da ich bei "401 Unauthorized" bleibe.

Wenn Du in Burp mit "intercept on" die Request von Postman mit Action > Send to repeater kopierst, und dann im Reiter Repeater manuell das Header Content-Type: application/x-www-form-urlencoded hinzufügst, kriegst Du auch 415?
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

amenomade

Hab bei developer@miele einen Antrag für client_id / client_secret mit Dummy Account geschickt. Mal sehen, ob die es mir geben, es wird ggf. einfacher.
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

xerion

Hallo amenomade erstmal vielen Dank dass du dich so intensiv um mein Problem kümmerst.
Wenn ich Content-Type: application/x-www-form-urlencoded über Burp hinzufüge, bekomme ich auch 415.
HTTP/1.1 415 Unsupported Media Type
Date: Fri, 18 Jan 2019 19:54:38 GMT
Content-Type: application/json
Content-Length: 56
Connection: close
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS
Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization
Strict-Transport-Security: max-age=15724800; includeSubDomains

{"code":415,"message":"HTTP 415 Unsupported Media Type"}
Ich würde mich  freuen, wenn du meinen Einladungscode für Tibber, der Stromanbieter, der dir hilft, deinen Stromverbrauch zu verstehen und zu reduzieren, nutzt: https://invite.tibber.com/5fc08jbs. So bekommen wir beide 50 Euro und 100 % Ökostrom / https://geld-fuer-eauto.de/ref/334561880