Miele 3rd party API in FHEM einbinden

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

Vorheriges Thema - Nächstes Thema

volschin

Intel NUC+Ubuntu 22.04+Docker+FHEM6
HomeMatic: HM-MOD-RPI-PCB+HM-USB-CFG2+hmland+diverse, HUE: Hue-Bridge, RaspBee+deCONZ+diverse
Amzn Dash-Buttons, Siro Rollos
4xRPi, 4xCO20, OWL+USB, HarmonyHub, FRITZ!Box 7590, Echo Dots+Show8, Logi Circle 2, HomeBridge
TIG Stack (Telegraf, InfluxDB, Grafana)

Fritz Muster

Danke für die Rückmeldung!

Viele Grüße
Fritz
RasPi 3B+, Stretch, Fhem 5.9, DBlog SQLite
HMLAN, mapleCUN MAX/WMBus, mapleSduino 868/433/868
HM Sensoren/Aktoren ,Technoline TX 29 DTH-IT, TFA 30.3155WD, MAX!
Hour Counter, Astro, EletricityCounter, Statistics, Charting Frontend, TabletUI, Modbus

volschin

Fakt ist aber leider auch, dass die Schnittstelle über die swagger-UI der Developer-Seite anscheinend sauber funktioniert.
Intel NUC+Ubuntu 22.04+Docker+FHEM6
HomeMatic: HM-MOD-RPI-PCB+HM-USB-CFG2+hmland+diverse, HUE: Hue-Bridge, RaspBee+deCONZ+diverse
Amzn Dash-Buttons, Siro Rollos
4xRPi, 4xCO20, OWL+USB, HarmonyHub, FRITZ!Box 7590, Echo Dots+Show8, Logi Circle 2, HomeBridge
TIG Stack (Telegraf, InfluxDB, Grafana)

volschin

Problem liegt anscheinend in der Beschaffung des Bearer Tokens.
Intel NUC+Ubuntu 22.04+Docker+FHEM6
HomeMatic: HM-MOD-RPI-PCB+HM-USB-CFG2+hmland+diverse, HUE: Hue-Bridge, RaspBee+deCONZ+diverse
Amzn Dash-Buttons, Siro Rollos
4xRPi, 4xCO20, OWL+USB, HarmonyHub, FRITZ!Box 7590, Echo Dots+Show8, Logi Circle 2, HomeBridge
TIG Stack (Telegraf, InfluxDB, Grafana)

volschin

Bearer Token hart anstatt $sid eingetragen und es läuft. Ist also definitiv ein Problem der Tokenbeschaffung.
Intel NUC+Ubuntu 22.04+Docker+FHEM6
HomeMatic: HM-MOD-RPI-PCB+HM-USB-CFG2+hmland+diverse, HUE: Hue-Bridge, RaspBee+deCONZ+diverse
Amzn Dash-Buttons, Siro Rollos
4xRPi, 4xCO20, OWL+USB, HarmonyHub, FRITZ!Box 7590, Echo Dots+Show8, Logi Circle 2, HomeBridge
TIG Stack (Telegraf, InfluxDB, Grafana)

volschin

Für mich sieht das nach erster Analyse sehr nach Bug aus. Ich frage mit einem fehlerhaften Bearer-Token an und müsste eigentlich einen 401 Unauthorized bekommen, es kommt aber ein 500.
Dadurch kann auch kein Authorization Flow gestartet werden.
Intel NUC+Ubuntu 22.04+Docker+FHEM6
HomeMatic: HM-MOD-RPI-PCB+HM-USB-CFG2+hmland+diverse, HUE: Hue-Bridge, RaspBee+deCONZ+diverse
Amzn Dash-Buttons, Siro Rollos
4xRPi, 4xCO20, OWL+USB, HarmonyHub, FRITZ!Box 7590, Echo Dots+Show8, Logi Circle 2, HomeBridge
TIG Stack (Telegraf, InfluxDB, Grafana)

volschin

Ich habe jetzt
reAuthRegex 500 Internal Server Error
gesetzt und schon funzt es wieder.

Bis Miele die nächste Änderung macht.  :(
Intel NUC+Ubuntu 22.04+Docker+FHEM6
HomeMatic: HM-MOD-RPI-PCB+HM-USB-CFG2+hmland+diverse, HUE: Hue-Bridge, RaspBee+deCONZ+diverse
Amzn Dash-Buttons, Siro Rollos
4xRPi, 4xCO20, OWL+USB, HarmonyHub, FRITZ!Box 7590, Echo Dots+Show8, Logi Circle 2, HomeBridge
TIG Stack (Telegraf, InfluxDB, Grafana)

xerion

Danke..... funktioniert bei mir auch wieder.

Gesendet von meinem JSN-L21 mit Tapatalk

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

Fritz Muster

Zitat von: volschin am 17 August 2019, 10:40:01
Ich habe jetzt
reAuthRegex 500 Internal Server Error
gesetzt und schon funzt es wieder.

Bis Miele die nächste Änderung macht.  :(

Habe das mal in meinem kleinen Tutorial angepasst.

Grüße Fritz

RasPi 3B+, Stretch, Fhem 5.9, DBlog SQLite
HMLAN, mapleCUN MAX/WMBus, mapleSduino 868/433/868
HM Sensoren/Aktoren ,Technoline TX 29 DTH-IT, TFA 30.3155WD, MAX!
Hour Counter, Astro, EletricityCounter, Statistics, Charting Frontend, TabletUI, Modbus

alkazaa

Hallo,
ich verfolge diesen thread mit großem Interesse, da ich auch versuche, ein Miele-Gerät in FHEM einzubinden.
Ich bekomme aber nur die berüchtigte Meldung
HTTP/1.1 401 Unauthorized
Date: Wed, 28 Aug 2019 15:00:23 GMT
Content-Type: text/html
Connection: close

obwohl ich über die Miele 3rd party API problemlos auf mein Gerät zugreifen kann.

Hier das listing meines httpmod device:
Internals:
   BUSY       0
   CHANGED   
   DEF        https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de 120
   FUUID      5d62d5f7-f33f-a50b-2bed-a45707ea58fbae04
   Interval   120
   JSONEnabled 1
   LASTSEND   1567003583.32655
   MainURL    https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de
   ModuleVersion 3.5.9 - 13.2.2019
   NAME       Dunsthaube
   NOTIFYDEV  global
   NR         61
   NTFY_ORDER 50-Dunsthaube
   STATE      ???
   TRIGGERTIME 1567003703.32461
   TRIGGERTIME_FMT 2019-08-28 16:48:23
   TYPE       HTTPMOD
   addr       https://api.mcs3.miele.com:443
   auth       0
   code       401
   compress   1
   conn       
   data       
   displayurl https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de
   header     Authorization: Bearer $sid
Content-Type: application/json
   host       api.mcs3.miele.com
   httpheader HTTP/1.1 401 Unauthorized
Date: Wed, 28 Aug 2019 14:46:23 GMT
Content-Type: text/html
Connection: close
   httpversion 1.0
   hu_blocking 0
   hu_filecount 334
   hu_port    443
   hu_portSfx
   ignoreredirects 0
   loglevel   4
   path       /v1/devices/000xxxxxxxxx/?language=de
   protocol   https
   redirects  0
   timeout    2
   url        https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de
   value      0
   QUEUE:
   READINGS:
     2019-08-26 19:11:22   Drehgeschwindigkeit-1 Drehgeschwindigkeit
     2019-08-26 19:11:22   Drehgeschwindigkeit-2 U/min
   REQUEST:
     data       
     header     Authorization: Bearer $sid
Content-Type: application/json
     ignoreredirects 0
     retryCount 0
     type       update
     url        https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de
     value      0
   sslargs:
Attributes:
   disable    0
   enableControlSet 1
   reAuthRegex 500 Internal Server Error
   reading01JSON Drehgeschwindigkeit
   reading01Name state_spinningSpeed
   requestHeader01 Authorization: Bearer $sid
   requestHeader02 Content-Type: application/json
   room       Haus
   sid1URL    https://api.mcs3.miele.com/thirdparty/login/?response_type=code&state=login&client_id=meine_clientID&scope=&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F
   sid2Data   email=mailadresse@gmx.de&password=xxxxxxxx&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F&state=login&response_type=code&client_id=meine_clientID&vgInformationSelector=de-DE
   sid2IdRegex (?s)code=(DE_[0-9a-f]+)
   sid2IgnoreRedirects 1
   sid2URL    https://api.mcs3.miele.com/oauth2/auth
   sid3Data   grant_type=authorization_code&code=$sid&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F&client_id=meine_clientID&client_secret=mein_secret
   sid3IdJSON access_token
   sid3URL    https://api.mcs3.miele.com/thirdparty/token/
   userattr   reading01JSON reading01Name requestHeader01 requestHeader02 sid1URL sid2Data sid2IdRegex sid2IgnoreRedirects:0,1 sid2URL sid3Data sid3IdJSON sid3URL
   verbose    5


Im Vergleich zu anderen listings weiter vorne in diesem thread fiel mir auf, dass bei meinem listing folgende Zeilen fehlen, die in den anderen listings nach der Zeile "Connection: close" auftauchen:
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


Was fehlt in meiner FHEM Installation?


amenomade

#115
Versuch mit
reAuthRegex 500.Internal.Server.Error|Unauthorized|default.backend...401
Ansonsten, bitte Log mit verbose 5 liefern

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

alkazaa

#116
Danke für die schnelle Reaktion!
(Das ist ein tolles Forum hier!!)

Also, nach dem geänderten reAuthRegex passiert folgendes (log Auszug mit verbose 5):
2019.08.28 19:12:24 4: Dunsthaube: GetUpdate called (update)
2019.08.28 19:12:24 4: Dunsthaube: update timer modified: will call GetUpdate in 120.0 seconds at 2019-08-28 19:14:24
2019.08.28 19:12:24 4: Dunsthaube: AddToQueue adds update, initial queue len: 0
2019.08.28 19:12:24 5: Dunsthaube: AddToQueue adds type update to URL https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de, no data, header Authorization: Bearer $sid
Content-Type: application/json, retry 0
2019.08.28 19:12:24 5: Dunsthaube: HandleSendQueue called, qlen = 1
2019.08.28 19:12:24 4: Dunsthaube: HandleSendQueue sends request type update to URL https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de, No Data,
header: Authorization: Bearer $sid
Content-Type: application/json
timeout 2
2019.08.28 19:12:24 5: HttpUtils url=https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de
2019.08.28 19:12:24 4: IP: api.mcs3.miele.com -> 157.97.106.171
2019.08.28 19:12:24 5: HttpUtils request header:
GET /v1/devices/000xxxxxxxxx/?language=de HTTP/1.0
Host: api.mcs3.miele.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Authorization: Bearer $sid
Content-Type: application/json

2019.08.28 19:12:24 4: https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de: HTTP response code 401
2019.08.28 19:12:24 5: HttpUtils https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de: Got data, length: 21
2019.08.28 19:12:24 5: HttpUtils response header:
HTTP/1.1 401 Unauthorized
Date: Wed, 28 Aug 2019 17:12:24 GMT
Content-Type: text/html
Connection: close
2019.08.28 19:12:24 4: Dunsthaube: Read callback: request type was update retry 0,
Body: default backend - 401
2019.08.28 19:12:24 3: Dunsthaube: error while parsing JSON data: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "default backend - 40...") at (eval 2270) line 1.

2019.08.28 19:12:24 5: Dunsthaube: ExtractSid called, context reading, num
2019.08.28 19:12:24 5: Dunsthaube: CheckAuth is checking buffer with ReAuthRegex 500 Internal Server Error
2019.08.28 19:12:24 4: Dunsthaube: CheckAuth decided no authentication required
2019.08.28 19:12:24 5: Dunsthaube: Read starts parsing response to update with defined readings: 01
2019.08.28 19:12:24 5: Dunsthaube: ExtractReading state_spinningSpeed with json Drehgeschwindigkeit ...
2019.08.28 19:12:24 5: Dunsthaube: ExtractReading state_spinningSpeed did not match
2019.08.28 19:12:24 3: Dunsthaube: Read response to update didn't match any Reading
2019.08.28 19:12:24 5: Dunsthaube: HandleSendQueue called, qlen = 0
2019.08.28 19:12:54 5: Dunsthaube: set called with reread
2019.08.28 19:12:54 4: Dunsthaube: GetUpdate called (reread)
2019.08.28 19:12:54 4: Dunsthaube: AddToQueue adds update, initial queue len: 0
2019.08.28 19:12:54 5: Dunsthaube: AddToQueue adds type update to URL https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de, no data, header Authorization: Bearer $sid
Content-Type: application/json, retry 0
2019.08.28 19:12:54 5: Dunsthaube: HandleSendQueue called, qlen = 1
2019.08.28 19:12:54 4: Dunsthaube: HandleSendQueue sends request type update to URL https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de, No Data,
header: Authorization: Bearer $sid
Content-Type: application/json
timeout 2
2019.08.28 19:12:54 5: HttpUtils url=https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de
2019.08.28 19:12:54 4: IP: api.mcs3.miele.com -> 157.97.106.171
2019.08.28 19:12:54 5: HttpUtils request header:
GET /v1/devices/000xxxxxxxxx/?language=de HTTP/1.0
Host: api.mcs3.miele.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Authorization: Bearer $sid
Content-Type: application/json

2019.08.28 19:12:54 4: https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de: HTTP response code 401
2019.08.28 19:12:54 5: HttpUtils https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de: Got data, length: 21
2019.08.28 19:12:54 5: HttpUtils response header:
HTTP/1.1 401 Unauthorized
Date: Wed, 28 Aug 2019 17:12:54 GMT
Content-Type: text/html
Connection: close
2019.08.28 19:12:54 4: Dunsthaube: Read callback: request type was update retry 0,
Body: default backend - 401
2019.08.28 19:12:54 3: Dunsthaube: error while parsing JSON data: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "default backend - 40...") at (eval 2279) line 1.

2019.08.28 19:12:54 5: Dunsthaube: ExtractSid called, context reading, num
2019.08.28 19:12:54 5: Dunsthaube: CheckAuth is checking buffer with ReAuthRegex reAuthRegex 500.Internal.Server.Error|Unauthorized|default.backend...401
2019.08.28 19:12:54 4: Dunsthaube: CheckAuth decided new authentication required
2019.08.28 19:12:54 4: Dunsthaube: Auth called with Steps: 1 2 3
2019.08.28 19:12:54 4: Dunsthaube: AddToQueue adds auth3, initial queue len: 0, prio
2019.08.28 19:12:54 5: Dunsthaube: AddToQueue prepends type auth3 to URL https://api.mcs3.miele.com/thirdparty/token/, data grant_type=authorization_code&code=$sid&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F&client_id=my_client-ID&client_secret=my_client-secret, no headers, retry 0
2019.08.28 19:12:54 4: Dunsthaube: AddToQueue adds auth2, initial queue len: 1, prio
2019.08.28 19:12:54 5: Dunsthaube: AddToQueue prepends type auth2 to URL https://api.mcs3.miele.com/oauth2/auth, data email=email@gmx.de&password=*******&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F&state=login&response_type=code&client_id=my_client-ID&vgInformationSelector=de-DE, no headers, ignore redirects, retry 0
2019.08.28 19:12:54 4: Dunsthaube: AddToQueue adds auth1, initial queue len: 2, prio
2019.08.28 19:12:54 5: Dunsthaube: AddToQueue prepends type auth1 to URL https://api.mcs3.miele.com/thirdparty/login/?response_type=code&state=login&client_id=my_client-ID&scope=&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F, no data, no headers, retry 0
2019.08.28 19:12:54 5: Dunsthaube: HandleSendQueue called, qlen = 3
2019.08.28 19:12:54 4: Dunsthaube: HandleSendQueue sends request type auth1 to URL https://api.mcs3.miele.com/thirdparty/login/?response_type=code&state=login&client_id=my_client-ID&scope=&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F, No Data, No Header
timeout 2
2019.08.28 19:12:54 5: HttpUtils url=https://api.mcs3.miele.com/thirdparty/login/?response_type=code&state=login&client_id=my_client-ID&scope=&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F
2019.08.28 19:12:54 4: IP: api.mcs3.miele.com -> 157.97.106.171
2019.08.28 19:12:54 4: Dunsthaube: AddToQueue adds update, initial queue len: 2
2019.08.28 19:12:54 5: Dunsthaube: AddToQueue adds type update to URL https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de, no data, header Authorization: Bearer $sid
Content-Type: application/json, retry 1
2019.08.28 19:12:54 5: Dunsthaube: HandleSendQueue called, qlen = 3
2019.08.28 19:12:54 5: Dunsthaube: HandleSendQueue - still waiting for reply to last request, delay sending from queue
2019.08.28 19:12:54 4: Dunsthaube: CheckAuth requeued request update after auth, retryCount 0 ...
2019.08.28 19:12:55 5: HttpUtils request header:
GET /thirdparty/login/?response_type=code&state=login&client_id=my_client-ID&scope=&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F HTTP/1.0
Host: api.mcs3.miele.com
User-Agent: fhem
Accept-Encoding: gzip,deflate

2019.08.28 19:12:55 4: https://api.mcs3.miele.com/thirdparty/login/?response_type=code&state=login&client_id=my_client-ID&scope=&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F: HTTP response code 200
2019.08.28 19:12:55 5: HttpUtils https://api.mcs3.miele.com/thirdparty/login/?response_type=code&state=login&client_id=my_client-ID&scope=&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F: Got data, length: 6307
2019.08.28 19:12:55 5: HttpUtils response header:
HTTP/1.1 200 OK
Date: Wed, 28 Aug 2019 17:12:55 GMT
Content-Type: text/html
Content-Length: 2210
Connection: close
Vary: Accept-Encoding
Content-Encoding: gzip
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: PUT, GET, POST, 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.08.28 19:12:55 4: Dunsthaube: Read callback: request type was auth1 retry 0,
Body: <html lang="de">
<head>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta charset="utf-8">
<!-- Suppress favicon request-->
<link rel="shortcut icon" type="image/x-icon"
href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAUAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/EwCL/xMAjP8TAIv/EgCL/xIAi/8TAIv/EgCL/xMAi/8SAIv/EwCL/xIAi/8TAIv/FACM/xQAjP8UAIz/FwON/yYUlf8bCY//KBaW/ysZmP8tG5j/JhSV/y4dmf8mFJX/KxmX/ygVlv8tG5j/JxSV/xQAjP8UAIz/EwCM/x4Lkf+BdsH/nJPO/7Ot2v+aks7/s63a/6Wd0/+9t9//lo3M/7Wv2/+noNT/vbff/5mQzf8mFJX/EwCL/xMAjP8cCJD/qaLV/8C64P+9uN//mpLO/4+GyP9pXLX/hnvE/3Fluv+1rtv/iH/F/4B2wf9zaLv/HQqR/xMAjP8UAIz/FwOO/zMhm/8mFZX/JxaV/y0bmP8fDZL/FwWO/xIAi/8VBI3/MiCa/yIRk/8SAIv/EgCL/xMAjP8UAIz/FACM/xQAjP8SAIv/EwCL/xMAi/8SAIv/EwCM/xQAjP8UAIz/FACM/xIAi/8TAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/FACM/xQAjP8UAIz/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==">
<!--Import Google Icon Font-->
<!--Import materialize.css-->
<!--Import own css-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="/assets/css/materialize.min.css?1556550173384">
<link type="text/css" rel="stylesheet" href="/assets/css/mieleStyle.css?1556550173387"
media="screen,projection"/>
<!-- Import scrips -->
<!-- Compiled and minified JavaScript -->
<script src="/assets/js/materialize.min.js?1556550173386"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
M.FormSelect.init(document.querySelectorAll('select'));
});
</script>
</head>
<body id="mieleLoginSite">
<div class="container">
<div class="row">
<div class="col s12 m8 offset-m2 offset-l2 l8">
<div class="center">
<img class="responsive-img"
src="/assets/images/miele_logo.svg" width="150" alt="miele.com"/>
</div>
<h1 class="center mediumFont">Login</h1>
<form method="post" action="/oauth/auth">
<div class="input-field">
<i class="material-icons prefix">account_circle</i>
<input required id="e-mail" type="email" name="email">
<label for="e-mail">Email Address</label>
</div>
<div class="input-field">
<i class="material-icons prefix">https</i>
<input required id="password" type="password" name="password">
<label for="password">Password</label>
</div>
<!-- add here all hidden inputs -->
<input type="hidden" name="response_type" value="code">
<input type="hidden" name="redirect_uri" value="https://api.mcs3.miele.com/thirdparty/login/">
<input type="hidden" name="state" value="login">
<input type="hidden" name="client_id" value="my_client-ID">
<div class="input-field" style="margin-top: 25px;">
<i class="material-icons prefix no-margin">language</i>
<select required name="vgInformationSelector" size="5">
<option value="" disabled>Please select your country</option>
<option value="et-EE">Miele Eesti</option>
<option value="de-DE">Miele Deutschland</option>
<option value="no-NO">Miele Norge</option>
<option value="sr-RS">Miele Србија</option>
<option value="nl-BE">Miele België</option>
<option value="fi-FI">Miele Suomi</option>
<option value="zh-HK">Miele Hong Kong</option>
<option value="ru-RU">Miele Россия</option>
<option value="en-AE">Miele United Arab Emirates</option>
<option value="pt-PT">Miele Portugual</option>
<option value="bg-BG">Miele България</option>
<option value="de-CH">Miele Schweiz</option>
<option value="en-IN">Miele India</option>
<option value="de-SX">Miele Semi Pro</option>
<option value="ja-JP">Miele Nihon</option>
<option value="da-DK">Miele Danmark</option>
<option value="ko-KR">Miele Hanguk</option>
<option value="en-ZA">Miele South Africa</option>
<option value="lt-LT">Miele Lietuva</option>
<option value="es-CL">Miele Chile</option>
<option value="de-LU">Miele Luxemburg</option>
<option value="hr-HR">Miele Croatia</option>
<option value="lv-LV">Miele Latvija</option>
<option value="zh-CN">Miele Zhōngguó</option>
<option value="el-GR">Miele Ελλάδα</option>
<option value="it-IT">Miele Italia</option>
<option value="es-MX">Miele México</option>
<option value="fr-FR">Miele France</option>
<option value="en-MY">Miele Malaysia</option>
<option value="en-NZ">Miele New Zealand</option>
<option value="ru-UA">Miele Україна</option>
<option value="hu-HU">Miele Magyarország</option>
<option value="es-ES">Miele España</option>
<option value="ru-KZ">Miele Казахстан</option>
<option value="sv-SE">Miele Sverige</option>
<option value="de-AT">Miele Österreich</option>
<option value="en-AU">Miele Australia</option>
<option value="en-SG">Miele Singapore</option>
<option value="en-TH">Miele Thailand</option>
<option value="el-CY">Miele Kypros</option>
<option value="sl-SI">Miele Slovenia</option>
<option value="ru-BY">Miele Беларуси</option>
<option value="cs-CZ">Miele Czechia</option>
<option value="sk-SK">Miele Slovensko</option>
<option value="en-GB">Miele UK</option>
<option value="en-IE">Miele Ireland</option>
<option value="pl-PL">Miele Polska</option>
<option value="ro-RO">Miele România</option>
<option value="en-CA">Miele Canada</option>
<option value="nl-NL">Miele Nederland</option>
<option value="tr-TR">Miele Türkiye</option>
<option value="en-US">Miele USA</option>
</select>
<label>Country</label>
</div>
<div class="center">
<button class="btn waves-effect waves-light miele-red"
type="submit">Submit</button>
</div>
</form>
</div>
</div>
</body>
</html>
2019.08.28 19:12:55 3: Dunsthaube: error while parsing JSON data: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "<html lang="de">\n<h...") at (eval 2281) line 1.

2019.08.28 19:12:55 5: Dunsthaube: ExtractSid called, context sid, num 1
2019.08.28 19:12:55 5: Dunsthaube: HandleSendQueue called, qlen = 3
2019.08.28 19:12:55 4: Dunsthaube: HandleSendQueue sends request type auth2 to URL https://api.mcs3.miele.com/oauth2/auth,
data: email=email@gmx.de&password=*******&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F&state=login&response_type=code&client_id=my_client-ID&vgInformationSelector=de-DE, No Header
timeout 2
2019.08.28 19:12:55 5: HttpUtils url=https://api.mcs3.miele.com/oauth2/auth
2019.08.28 19:12:55 4: IP: api.mcs3.miele.com -> 157.97.106.171
2019.08.28 19:12:56 5: HttpUtils request header:
POST /oauth2/auth HTTP/1.0
Host: api.mcs3.miele.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Content-Length: 221
Content-Type: application/x-www-form-urlencoded

2019.08.28 19:12:56 4: https://api.mcs3.miele.com/oauth2/auth: HTTP response code 401
2019.08.28 19:12:56 5: HttpUtils https://api.mcs3.miele.com/oauth2/auth: Got data, length: 21
2019.08.28 19:12:56 5: HttpUtils response header:
HTTP/1.1 401 Unauthorized
Date: Wed, 28 Aug 2019 17:12:56 GMT
Content-Type: text/html
Connection: close
2019.08.28 19:12:56 4: Dunsthaube: Read callback: request type was auth2 retry 0,
Body: default backend - 401
2019.08.28 19:12:56 3: Dunsthaube: error while parsing JSON data: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "default backend - 40...") at (eval 2285) line 1.

2019.08.28 19:12:56 5: Dunsthaube: ExtractSid called, context sid, num 2
2019.08.28 19:12:56 5: Dunsthaube: ExtractSid could not match buffer to IdRegex (?s)code=(DE_[0-9a-f]+)
2019.08.28 19:12:56 5: Dunsthaube: HandleSendQueue called, qlen = 2
2019.08.28 19:12:56 4: Dunsthaube: HandleSendQueue sends request type auth3 to URL https://api.mcs3.miele.com/thirdparty/token/,
data: grant_type=authorization_code&code=$sid&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F&client_id=my_client-ID&client_secret=my_client-secret, No Header
timeout 2
2019.08.28 19:12:56 5: HttpUtils url=https://api.mcs3.miele.com/thirdparty/token/
2019.08.28 19:12:56 4: IP: api.mcs3.miele.com -> 157.97.106.171
2019.08.28 19:12:57 5: HttpUtils request header:
POST /thirdparty/token/ HTTP/1.0
Host: api.mcs3.miele.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Content-Length: 203
Content-Type: application/x-www-form-urlencoded

2019.08.28 19:12:57 4: https://api.mcs3.miele.com/thirdparty/token/: HTTP response code 500
2019.08.28 19:12:57 5: HttpUtils https://api.mcs3.miele.com/thirdparty/token/: Got data, length: 42
2019.08.28 19:12:57 5: HttpUtils response header:
HTTP/1.1 500 Internal Server Error
Date: Wed, 28 Aug 2019 17:12:57 GMT
Content-Type: text/plain
Content-Length: 42
Connection: close
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: PUT, GET, POST, 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.08.28 19:12:57 4: Dunsthaube: Read callback: request type was auth3 retry 0,
Body: no vg given. grant_type=AUTHORIZATION_CODE
2019.08.28 19:12:57 3: Dunsthaube: error while parsing JSON data: 'null' expected, at character offset 0 (before "no vg given. grant_t...") at (eval 2287) line 1.

2019.08.28 19:12:57 5: Dunsthaube: ExtractSid called, context sid, num 3
2019.08.28 19:12:57 5: Dunsthaube: Checking SID with JSON access_token
2019.08.28 19:12:57 5: Dunsthaube: HandleSendQueue called, qlen = 1
2019.08.28 19:12:57 4: Dunsthaube: HandleSendQueue sends request type update to URL https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de, No Data,
header: Authorization: Bearer $sid
Content-Type: application/json
timeout 2
2019.08.28 19:12:57 5: HttpUtils url=https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de
2019.08.28 19:12:57 4: IP: api.mcs3.miele.com -> 157.97.106.171
2019.08.28 19:12:58 5: HttpUtils request header:
GET /v1/devices/000xxxxxxxxx/?language=de HTTP/1.0
Host: api.mcs3.miele.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Authorization: Bearer $sid
Content-Type: application/json

2019.08.28 19:12:58 4: https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de: HTTP response code 401
2019.08.28 19:12:58 5: HttpUtils https://api.mcs3.miele.com/v1/devices/000xxxxxxxxx/?language=de: Got data, length: 21
2019.08.28 19:12:58 5: HttpUtils response header:
HTTP/1.1 401 Unauthorized
Date: Wed, 28 Aug 2019 17:12:58 GMT
Content-Type: text/html
Connection: close
2019.08.28 19:12:58 4: Dunsthaube: Read callback: request type was update retry 1,
Body: default backend - 401
2019.08.28 19:12:58 3: Dunsthaube: error while parsing JSON data: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "default backend - 40...") at (eval 2289) line 1.

2019.08.28 19:12:58 5: Dunsthaube: ExtractSid called, context reading, num
2019.08.28 19:12:58 5: Dunsthaube: CheckAuth is checking buffer with ReAuthRegex reAuthRegex 500.Internal.Server.Error|Unauthorized|default.backend...401
2019.08.28 19:12:58 4: Dunsthaube: CheckAuth decided new authentication required
2019.08.28 19:12:58 4: Dunsthaube: Authentication still required but no retries left - did last authentication fail?
2019.08.28 19:12:58 5: Dunsthaube: Read starts parsing response to update with defined readings: 01
2019.08.28 19:12:58 5: Dunsthaube: ExtractReading state_spinningSpeed with json Drehgeschwindigkeit ...
2019.08.28 19:12:58 5: Dunsthaube: ExtractReading state_spinningSpeed did not match
2019.08.28 19:12:58 3: Dunsthaube: Read response to update didn't match any Reading
2019.08.28 19:12:58 5: Dunsthaube: HandleSendQueue called, qlen = 0


Dabei ist die Aktivität um 19:12:24 das letzte der alle 2 Minuten stattfindenden "GetUpdate called (update)", und ab 19:12:54 passiert das manuell gestartete reread ("set called with reread").

Nochmals Danke fürs Kümmern!

amenomade

Er kriegt kein DE_xxxxx Code.

Wenn die folgende Seite in einem Browser aufrufst:
https://api.mcs3.miele.com/thirdparty/login/?response_type=code&state=login&client_id=DEIN_CLIENTID&scope=&redirect_uri=https%3A%2F%2Fapi.mcs3.miele.com%2Fthirdparty%2Flogin%2F
(mit richtigem DEIN_CLIENTID), und dich dort anmeldest, kriegst Du in der zurückgelieferte URL
https://api.mcs3.miele.com/thirdparty/login/?code=DE_xxxxxxxxxxxxxxxxxxxxxxxxxx&state=login?
(nur die URL ist interessant, der Inhalt der Seite ist unrelevant - vermutlich ist es "Kontoverknüpfung fehlgeschlagen!", macht aber nichts)

Wenn nicht, prüfe dein ClientID und deine Zugangsdaten, die stimmen nicht miteinander

Wenn OK, dann prüfe in deiner HTTPMOD Definition die gleiche Daten: ClientID, ClientSecret, user, passwort
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

alkazaa

Sorry, ich hätte sagen sollen, dass ich den Test schon gemacht hatte, und es gab so einen DE_xxxxx code in der URL.

Und über https://www.miele.com/developer/swagger-ui/index.html kann ich mich mit der client_ID, dem client_secret sowie der email-adresse und passwort (alle per Strg_C und Strg-V aus FHEM rüberkopiert) erfolgreich "authorizen" lassen. Ich kann dann anschließend z.B. den  "GET ​/v1​/devices​/" Test-case ausführen und finde in der Antwort die korrekte Seriennummer des Geräts.

Ich denke, irgendwas anderes muss bei meinem setup faul sein.

amenomade

Zitat von: alkazaa am 28 August 2019, 20:39:27
Sorry, ich hätte sagen sollen, dass ich den Test schon gemacht hatte, und es gab so einen DE_xxxxx code in der URL.
Kommt aber nicht zurück beim HTTPMOD. Ist dein Client-Secret bei sid1URL und sid2Data richtig? Email und Passwort auch?
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus