Autor Thema: Nibe mittels HTTPMOD und API  (Gelesen 2243 mal)

Offline uwirt

  • Full Member
  • ***
  • Beiträge: 237
  • "I'm sorry, Dave. I'm afraid I can't do that."
Nibe mittels HTTPMOD und API
« am: 04 Februar 2020, 10:26:51 »
Hallo alle,

ich versuche meine Niebe Wärrmepumpe mittels HTTPMOD und das API von niebeuplink zum sprechen zu bringen. Ich habe mich dafür an die Anbindung von der Miele API hier (https://forum.fhem.de/index.php/topic,95989.msg935872.html#msg935872) gehalten.

Was ich bisher habe ist:


defmod Nibe HTTPMOD https://api.nibeuplink.com/api/v1/systems/29054/ 60
attr Nibe userattr reading100JSON reading100Name reading101JSON reading101Name reading102JSONrequestHeader01 requestHeader01 requestHeader02 requestHeader1 sid1Data sid1Header01 sid1IdJSON sid1IgnoreRedirects:0,1 sid1URL sid2Data sid2IdRegex sid2IgnoreRedirects:0,1 sid2URL sid3Data sid3IdJSON sid3URL
attr Nibe devStateStyle style="text-align:right;;;;"
attr Nibe enableControlSet 1
attr Nibe enableCookies 1
attr Nibe extractAllJSON 1
attr Nibe reAuthJSON message
attr Nibe reAuthRegex 500.Internal.Server.Error|Unauthorized|default.backend...401
attr Nibe requestHeader01 Authorization: Bearer $id
attr Nibe requestHeader02 Content-Type: application/json
attr Nibe sid1Data response_type=code&state=login&client_id=XXXX=READSYSTEM&redirect_uri=YYYY
attr Nibe sid1Header01 Content-Type: application/json
attr Nibe sid1URL https://api.nibeuplink.com/Account/LogIn
attr Nibe sid2Data response_type=code&client_id=XXXX&scope=READSYSTEM&redirect_uri=YYYY&state=STATE
attr Nibe sid2IgnoreRedirects 1
attr Nibe sid2URL https://api.nibeuplink.com/oauth/authorize
attr Nibe sid3Data grant_type=authorization_code&code=$sid&redirect_uri=XXXX&client_id=XXXX&client_secret=ZZZZ&scope=READSYSTEM
attr Nibe sid3IdJSON token
attr Nibe sid3URL https://api.nibeuplink.com/oauth/token
attr Nibe stateFormat https://api.nibeuplink.com
attr Nibe verbose 3

setstate Nibe https://api.nibeuplink.com
setstate Nibe 2020-02-04 10:15:02 details_0 Internal Server Error
setstate Nibe 2020-02-04 10:15:02 errorCode 0
setstate Nibe 2020-02-04 10:15:02 httpStatusCode 500
setstate Nibe 2020-01-27 14:11:36 message
setstate Nibe 2020-02-04 10:15:02 timestamp 2020-02-04T09:15:02.1874844Z


Leider bisher ohne Erfolg. Vielleicht hat hier jemand Erfahrung mit OAUTH2?

Besten Dank
« Letzte Änderung: 07 Februar 2020, 11:04:04 von uwirt »
FHEM / Ubuntu / fitlet2
HomeMatic: CCU3|HmIP-STHD|HmIP-PCBS|HmIP-PCBS2|HmIP-PCBS-BAT|HM-WDC7000|HM-WDS100-C6-O|HM-WDS40|HM-LC-Sw1-FM|HM-LC-RGBW-WM|HM-ES-PMSw1-Pl|HM-ES-TX-WM
NAS: DS218+|DS209j|DS216+II|DS412+
Devices: Panasonic Webcams|Withings|Gardena Smart

Offline amenomade

  • Developer
  • Hero Member
  • ****
  • Beiträge: 7449
Antw:NIebe mittels HTTPMOD und API
« Antwort #1 am: 04 Februar 2020, 18:56:57 »
"list" von Nibe, und Logauszug mit verbose 5 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

Offline uwirt

  • Full Member
  • ***
  • Beiträge: 237
  • "I'm sorry, Dave. I'm afraid I can't do that."
Antw:Nibe mittels HTTPMOD und API
« Antwort #2 am: 05 Februar 2020, 10:49:19 »
Hier mein List:


Internals:
   BUSY       0
   DEF        https://api.nibeuplink.com/api/v1/systems 60
   FUUID      5e2ed3d4-f33f-f92b-ab5a-c553351977df6adb
   Interval   60
   JSONEnabled 1
   LASTSEND   1580896059.41056
   LastAuthTry 2020-02-05 10:47:36
   MainURL    https://api.nibeuplink.com/api/v1/systems
   ModuleVersion 3.5.21 - 27.12.2019
   NAME       Nibe
   NOTIFYDEV  global
   NR         92
   NTFY_ORDER 50-Nibe
   STATE      https://api.nibeuplink.com
   TRIGGERTIME 1580896116.00936
   TRIGGERTIME_FMT 2020-02-05 10:48:36
   TYPE       HTTPMOD
   addr       https://api.nibeuplink.com:443
   auth       0
   buf       
   code       500
   compress   1
   conn       
   data       
   displayurl https://api.nibeuplink.com/api/v1/systems
   header     Authorization: Bearer $sid
Content-Type: application/json
Cookie: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
   host       api.nibeuplink.com
   httpheader HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 164
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Feb 2020 09:47:38 GMT
Connection: close
   httpversion 1.0
   hu_blocking 0
   hu_filecount 395
   hu_port    443
   hu_portSfx
   ignoreredirects 1
   loglevel   4
   path       /api/v1/systems
   protocol   https
   redirects  0
   timeout    2
   url        https://api.nibeuplink.com/api/v1/systems
   value      0
   CompiledRegexes:
   HTTPCookieHash:
     ARRAffinity;:
       Name       ARRAffinity
       Options    Path=/;HttpOnly;Domain=api.nibeuplink.com
       Path       
       Value      accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
   QUEUE:
   READINGS:
     2020-02-05 10:47:39   details_0       Internal Server Error
     2020-02-05 10:47:39   errorCode       0
     2020-02-05 10:47:39   httpStatusCode  500
     2020-01-27 14:11:36   message         
     2020-02-05 10:47:39   timestamp       2020-02-05T09:47:39.5451323Z
   REQUEST:
     data       
     header     Authorization: Bearer $sid
Content-Type: application/json
     ignoreredirects 0
     retryCount 1
     type       update
     url        https://api.nibeuplink.com/api/v1/systems
     value      0
   defptr:
     readingBase:
       details_0  reading
       errorCode  reading
       httpStatusCode reading
       timestamp  reading
     readingNum:
       details_0 
       errorCode 
       httpStatusCode
       timestamp 
     readingOutdated:
     requestReadings:
       update:
         details_0  reading
         errorCode  reading
         httpStatusCode reading
         timestamp  reading
   sslargs:
Attributes:
   devStateStyle style="text-align:right;;"
   enableControlSet 1
   enableCookies 1
   extractAllJSON 1
   reAuthJSON message
   reAuthRegex 500.Internal.Server.Error|Unauthorized|default.backend...401
   requestHeader01 Authorization: Bearer $sid
   requestHeader02 Content-Type: application/json
   sid1Data   response_type=code&state=login&client_id=XXXX&scope=READSYSTEM&redirect_uri=http://192.168.1.106/nibe/
   sid1Header01 Content-Type: application/json
   sid1URL    https://api.nibeuplink.com/Account/LogIn
   sid2Data   response_type=code&client_id=XXXX&scope=READSYSTEM&redirect_uri=http://192.168.1.106/nibe/&state=STATE
   sid2IgnoreRedirects 1
   sid2URL    https://api.nibeuplink.com/oauth/authorize
   sid3Data   grant_type=authorization_code&code=client_id=XXXX&client_secret=YYYY&code=$sid&redirect_uri=http://192.168.1.106/nibe/&scope=READSYSTEM
   sid3IdJSON token
   sid3URL    https://api.nibeuplink.com/oauth/token
   stateFormat https://api.nibeuplink.com
   userattr   requestData03 requestHeader01 requestHeader02 requestHeader1 sid1Data sid1Header01 sid1IdJSON sid1IgnoreRedirects:0,1 sid1URL sid2Data sid2IdRegex sid2IgnoreRedirects:0,1 sid2URL sid3Data sid3IdJSON sid3URL
   verbose    5


Der Auszug aus dem LogFile:


2020.02.05 11:40:41 5: Nibe: GetUpdate called (update)
2020.02.05 11:40:41 5: Nibe: update timer modified: will call GetUpdate in 60.0 seconds at 2020-02-05 11:41:41
2020.02.05 11:40:41 5: Nibe: AddToQueue adds type update to URL https://api.nibeuplink.com/api/v1/systems, no data, header Authorization: Bearer $sid
Content-Type: application/json, retry 0, initial queue len: 0
2020.02.05 11:40:41 5: Nibe: HandleSendQueue called, qlen = 1
2020.02.05 11:40:41 5: Nibe: HandleSendQueue is using Cookie ARRAffinity with path  and Value accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291 (key ARRAffinity;, destination path is /api/v1/systems)
2020.02.05 11:40:41 5: Nibe: HandleSendQueue is adding Cookie header: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
2020.02.05 11:40:41 4: Nibe: HandleSendQueue sends update with timeout 2 to https://api.nibeuplink.com/api/v1/systems, No Data,
header: Authorization: Bearer $sid
Content-Type: application/json
Cookie: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
2020.02.05 11:40:41 5: HttpUtils url=https://api.nibeuplink.com/api/v1/systems
2020.02.05 11:40:41 4: IP: api.nibeuplink.com -> 13.95.125.246
2020.02.05 11:40:41 5: HttpUtils request header:
GET /api/v1/systems HTTP/1.0
Host: api.nibeuplink.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Authorization: Bearer $sid
Content-Type: application/json
Cookie: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291

2020.02.05 11:40:41 4: https://api.nibeuplink.com/api/v1/systems: HTTP response code 500
2020.02.05 11:40:41 5: HttpUtils https://api.nibeuplink.com/api/v1/systems: Got data, length: 164
2020.02.05 11:40:41 5: HttpUtils response header:
HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 164
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Feb 2020 10:40:40 GMT
Connection: close
2020.02.05 11:40:41 4: Nibe: Read callback: request type was update retry 0,
header: HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 164
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Feb 2020 10:40:40 GMT
Connection: close, body length 164
2020.02.05 11:40:41 5: Nibe: Read callback: body
{
  "httpStatusCode": 500,
  "errorCode": 0,
  "timestamp": "2020-02-05T10:40:41.1994573Z",
  "details": [
    "Internal Server Error"
  ],
  "data": null
}
2020.02.05 11:40:41 4: Nibe: Read found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.02.05 11:40:41 4: Nibe: Read is decoding the buffer as utf-8
2020.02.05 11:40:41 5: Nibe: JSON Flatter called : prefix , ref is HASH(0x5614b5070fe8)
2020.02.05 11:40:41 5: Nibe: JSON Flatter sets errorCode to 0
2020.02.05 11:40:41 5: Nibe: JSON Flatter sets timestamp to 2020-02-05T10:40:41.1994573Z
2020.02.05 11:40:41 5: Nibe: JSON Flatter doing recursion because value is a ARRAY
2020.02.05 11:40:41 5: Nibe: JSON Flatter called : prefix details_, ref is ARRAY(0x5614b57d71b8)
2020.02.05 11:40:41 5: Nibe: JSON Flatter sets details_0 to Internal Server Error
2020.02.05 11:40:41 5: Nibe: JSON Flatter sets httpStatusCode to 500
2020.02.05 11:40:41 4: Nibe: extracted JSON values to internal
2020.02.05 11:40:41 5: Nibe: GetCookies is looking for Cookies
2020.02.05 11:40:41 5: Nibe: ExtractSid called, context reading, num
2020.02.05 11:40:41 4: Nibe: checking for redirects, code=500, ignore=0
2020.02.05 11:40:41 4: Nibe: no redirects to handle
2020.02.05 11:40:41 5: Nibe: GetRegex found precompiled reAuthRegex for  as (?^:500.Internal.Server.Error|Unauthorized|default.backend...401)
2020.02.05 11:40:41 5: Nibe: Checking Auth with JSON message
2020.02.05 11:40:41 5: Nibe: CheckAuth is checking buffer with ReAuthRegex (?^:500.Internal.Server.Error|Unauthorized|default.backend...401)
2020.02.05 11:40:41 4: Nibe: CheckAuth decided new authentication required
2020.02.05 11:40:41 4: Nibe: Auth called with Steps: 1 2 3
2020.02.05 11:40:41 5: Nibe: AddToQueue prepends type auth3 to URL https://api.nibeuplink.com/oauth/token, data grant_type=authorization_code&code=client_id=XXXX&client_secret=YYYY&code=$sid&redirect_uri=http://192.168.1.106/nibe/&scope=READSYSTEM, no headers, retry 0, initial queue len: 0
2020.02.05 11:40:41 5: Nibe: AddToQueue prepends type auth2 to URL https://api.nibeuplink.com/oauth/authorize, data response_type=code&client_id=XXXX&scope=READSYSTEM&redirect_uri=http://192.168.1.106/nibe/&state=STATE, no headers, ignore redirects, retry 0, initial queue len: 1
2020.02.05 11:40:41 5: Nibe: AddToQueue prepends type auth1 to URL https://api.nibeuplink.com/Account/LogIn, data response_type=code&state=login&client_id=XXXX&scope=READSYSTEM&redirect_uri=http://192.168.1.106/nibe/, header Content-Type: application/json, retry 0, initial queue len: 2
2020.02.05 11:40:41 5: Nibe: HandleSendQueue called, qlen = 3
2020.02.05 11:40:41 5: Nibe: HandleSendQueue - minSendDelay not over, rescheduling
2020.02.05 11:40:41 5: Nibe: AddToQueue adds type update to URL https://api.nibeuplink.com/api/v1/systems, no data, header Authorization: Bearer $sid
Content-Type: application/json, retry 1, initial queue len: 3
2020.02.05 11:40:41 5: Nibe: HandleSendQueue called, qlen = 4
2020.02.05 11:40:41 5: Nibe: HandleSendQueue - minSendDelay not over, rescheduling
2020.02.05 11:40:41 4: Nibe: CheckAuth requeued request update after auth, retryCount 0 ...
2020.02.05 11:40:42 5: Nibe: HandleSendQueue called, qlen = 4
2020.02.05 11:40:42 5: Nibe: HandleSendQueue is using Cookie ARRAffinity with path  and Value accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291 (key ARRAffinity;, destination path is /Account/LogIn)
2020.02.05 11:40:42 5: Nibe: HandleSendQueue is adding Cookie header: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
2020.02.05 11:40:42 4: Nibe: HandleSendQueue sends auth1 with timeout 2 to https://api.nibeuplink.com/Account/LogIn,
data: response_type=code&state=login&client_id=XXXX&scope=READSYSTEM&redirect_uri=http://192.168.1.106/nibe/,
header: Content-Type: application/json
Cookie: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
2020.02.05 11:40:42 5: HttpUtils url=https://api.nibeuplink.com/Account/LogIn
2020.02.05 11:40:42 4: IP: api.nibeuplink.com -> 13.95.125.246
2020.02.05 11:40:42 5: HttpUtils request header:
POST /Account/LogIn HTTP/1.0
Host: api.nibeuplink.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Content-Type: application/json
Cookie: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
Content-Length: 130

2020.02.05 11:40:42 4: https://api.nibeuplink.com/Account/LogIn: HTTP response code 500
2020.02.05 11:40:42 5: HttpUtils https://api.nibeuplink.com/Account/LogIn: Got data, length: 2768
2020.02.05 11:40:42 5: HttpUtils response header:
HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Length: 2768
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/10.0
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Feb 2020 10:40:42 GMT
Connection: close
2020.02.05 11:40:42 4: Nibe: Read callback: request type was auth1 retry 0,
header: HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Length: 2768
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/10.0
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Feb 2020 10:40:42 GMT
Connection: close, body length 2768
2020.02.05 11:40:42 5: Nibe: Read callback: body

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Error 500: Internal Server Error - NIBE Uplink™ API</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
  <link href="/Content/css?v=8-RQ-3oGItP3xx7qOWrv24qTFezA58K07jGd7iKzfu81" rel="stylesheet"/>

  <script src="/bundles/modernizr-respond?v=CqXYebK4-IyZhhv6CMVr3JbOHRqcPPoHkVZsC-ng0ZA1"></script>

  <!--[if !IE 7]>
    <style type="text/css">
      #wrap {display:table;height:100%}
    </style>
  <![endif]-->
</head>
<body>
  <input type="checkbox" id="show-menu" role="button">
  <nav class="header-menu">
    <ul>
      <li><a href="/Home/About">ABOUT</a></li>
        <li><a href="/Account/LogIn?mobile=False">LOG IN</a></li>
    </ul>
  </nav>
  <div id="wrap">
    <!--[if lt IE 7]>
        <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
    <![endif]-->
    <div class="header-container">
      <header class="wrapper clearfix">
        <label for="show-menu" class="show-menu">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </label>
        <div class="img-container">
          <a href="/"><img src="/Content/Images/nibe-uplink-api-238px-grey.png" alt="NIBE Uplink&trade;" /></a>
        </div>
      </header>
    </div>
    <div class="main-container">
      <div class="main wrapper clearfix">
       


<article>
  <header>
    <div class="content-wrapper">
      <div class="float-left">
        <h1>Unable to fulfil your request</h1>
        <p>The server could not fulfil your request.</p>
      </div>
    </div>
  </header>
  <section>
    <p><i>Error 500: Internal Server Error</i></p>
  </section>
</article>

      </div> <!-- #main -->
    </div> <!-- #main-container -->
  </div>
  <div class="footer-container">
    <footer class="wrapper">
      <img src="/Content/Images/nibe-energy-systems-90px-white.png" alt="NIBE Energy Systems" />
      <p>&copy; NIBE Energy Systems</p>
    </footer>
  </div>
  <script src="/bundles/jquery?v=DilzeZuJxdbQsfc_JOwsWB4VFDhTPM73urYeggaKdL81"></script>

 
</body>
</html>

2020.02.05 11:40:42 4: Nibe: Read found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.02.05 11:40:42 4: Nibe: Read is decoding the buffer as utf-8
2020.02.05 11:40:42 3: Nibe: error while parsing JSON data: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 2 (before "<!DOCTYPE html>\r\n<...") at (eval 21554) line 1.

2020.02.05 11:40:42 5: Nibe: GetCookies is looking for Cookies
2020.02.05 11:40:42 5: Nibe: ExtractSid called, context sid, num 1
2020.02.05 11:40:42 4: Nibe: checking for redirects, code=500, ignore=0
2020.02.05 11:40:42 4: Nibe: no redirects to handle
2020.02.05 11:40:43 5: Nibe: HandleSendQueue called, qlen = 3
2020.02.05 11:40:43 5: Nibe: HandleSendQueue is using Cookie ARRAffinity with path  and Value accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291 (key ARRAffinity;, destination path is /oauth/authorize)
2020.02.05 11:40:43 5: Nibe: HandleSendQueue is adding Cookie header: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
2020.02.05 11:40:43 4: Nibe: HandleSendQueue sends auth2 with timeout 2 to https://api.nibeuplink.com/oauth/authorize,
data: response_type=code&client_id=XXXX&scope=READSYSTEM&redirect_uri=http://192.168.1.106/nibe/&state=STATE,
header: Cookie: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
2020.02.05 11:40:43 5: HttpUtils url=https://api.nibeuplink.com/oauth/authorize
2020.02.05 11:40:43 4: IP: api.nibeuplink.com -> 13.95.125.246
2020.02.05 11:40:43 5: HttpUtils request header:
POST /oauth/authorize HTTP/1.0
Host: api.nibeuplink.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Cookie: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
Content-Length: 130
Content-Type: application/x-www-form-urlencoded

2020.02.05 11:40:43 4: https://api.nibeuplink.com/oauth/authorize: HTTP response code 302
2020.02.05 11:40:43 5: HttpUtils https://api.nibeuplink.com/oauth/authorize: Got data, length: 178
2020.02.05 11:40:43 5: HttpUtils response header:
HTTP/1.1 302 Found
Cache-Control: private
Content-Length: 178
Content-Type: text/html; charset=utf-8
Location: /Account/LogIn?mobile=true&ReturnUrl=%2foauth%2fauthorize
Server: Microsoft-IIS/10.0
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Feb 2020 10:40:42 GMT
Connection: close
2020.02.05 11:40:43 4: Nibe: Read callback: request type was auth2 retry 0,
header: HTTP/1.1 302 Found
Cache-Control: private
Content-Length: 178
Content-Type: text/html; charset=utf-8
Location: /Account/LogIn?mobile=true&ReturnUrl=%2foauth%2fauthorize
Server: Microsoft-IIS/10.0
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Feb 2020 10:40:42 GMT
Connection: close, body length 178
2020.02.05 11:40:43 5: Nibe: Read callback: body
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/Account/LogIn?mobile=true&amp;ReturnUrl=%2foauth%2fauthorize">here</a>.</h2>
</body></html>

2020.02.05 11:40:43 4: Nibe: Read found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.02.05 11:40:43 4: Nibe: Read is decoding the buffer as utf-8
2020.02.05 11:40:43 3: Nibe: error while parsing JSON data: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "<html><head><title>O...") at (eval 21556) line 1.

2020.02.05 11:40:43 5: Nibe: GetCookies is looking for Cookies
2020.02.05 11:40:43 5: Nibe: ExtractSid called, context sid, num 2
2020.02.05 11:40:43 4: Nibe: checking for redirects, code=302, ignore=1
2020.02.05 11:40:43 4: Nibe: ignoring redirect to https://api.nibeuplink.com:443/Account/LogIn?mobile=true&ReturnUrl=%2foauth%2fauthorize
2020.02.05 11:40:44 5: Nibe: HandleSendQueue called, qlen = 2
2020.02.05 11:40:44 5: Nibe: HandleSendQueue is using Cookie ARRAffinity with path  and Value accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291 (key ARRAffinity;, destination path is /oauth/token)
2020.02.05 11:40:44 5: Nibe: HandleSendQueue is adding Cookie header: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
2020.02.05 11:40:44 4: Nibe: HandleSendQueue sends auth3 with timeout 2 to https://api.nibeuplink.com/oauth/token,
data: grant_type=authorization_code&code=client_id=XXXX&client_secret=YYYY&code=$sid&redirect_uri=http://192.168.1.106/nibe/&scope=READSYSTEM,
header: Cookie: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
2020.02.05 11:40:44 5: HttpUtils url=https://api.nibeuplink.com/oauth/token
2020.02.05 11:40:44 4: IP: api.nibeuplink.com -> 13.95.125.246
2020.02.05 11:40:44 5: HttpUtils request header:
POST /oauth/token HTTP/1.0
Host: api.nibeuplink.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Cookie: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
Content-Length: 203
Content-Type: application/x-www-form-urlencoded

2020.02.05 11:40:44 4: https://api.nibeuplink.com/oauth/token: HTTP response code 400
2020.02.05 11:40:44 5: HttpUtils https://api.nibeuplink.com/oauth/token: Got data, length: 27
2020.02.05 11:40:44 5: HttpUtils response header:
HTTP/1.1 400 Bad Request
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Content-Length: 27
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/10.0
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Feb 2020 10:40:43 GMT
Connection: close
2020.02.05 11:40:44 4: Nibe: Read callback: request type was auth3 retry 0,
header: HTTP/1.1 400 Bad Request
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Content-Length: 27
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/10.0
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Feb 2020 10:40:43 GMT
Connection: close, body length 27
2020.02.05 11:40:44 5: Nibe: Read callback: body
{"error":"invalid_request"}
2020.02.05 11:40:44 4: Nibe: Read found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.02.05 11:40:44 4: Nibe: Read is decoding the buffer as utf-8
2020.02.05 11:40:44 5: Nibe: JSON Flatter called : prefix , ref is HASH(0x5614b5649748)
2020.02.05 11:40:44 5: Nibe: JSON Flatter sets error to invalid_request
2020.02.05 11:40:44 4: Nibe: extracted JSON values to internal
2020.02.05 11:40:44 5: Nibe: GetCookies is looking for Cookies
2020.02.05 11:40:44 5: Nibe: ExtractSid called, context sid, num 3
2020.02.05 11:40:44 5: Nibe: Checking SID with JSON token
2020.02.05 11:40:44 4: Nibe: checking for redirects, code=400, ignore=0
2020.02.05 11:40:44 4: Nibe: no redirects to handle
2020.02.05 11:40:45 5: Nibe: HandleSendQueue called, qlen = 1
2020.02.05 11:40:45 5: Nibe: HandleSendQueue is using Cookie ARRAffinity with path  and Value accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291 (key ARRAffinity;, destination path is /api/v1/systems)
2020.02.05 11:40:45 5: Nibe: HandleSendQueue is adding Cookie header: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
2020.02.05 11:40:45 4: Nibe: HandleSendQueue sends update with timeout 2 to https://api.nibeuplink.com/api/v1/systems, No Data,
header: Authorization: Bearer $sid
Content-Type: application/json
Cookie: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291
2020.02.05 11:40:45 5: HttpUtils url=https://api.nibeuplink.com/api/v1/systems
2020.02.05 11:40:45 4: IP: api.nibeuplink.com -> 13.95.125.246
2020.02.05 11:40:45 5: HttpUtils request header:
GET /api/v1/systems HTTP/1.0
Host: api.nibeuplink.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Authorization: Bearer $sid
Content-Type: application/json
Cookie: ARRAffinity=accb56b11a90a4702d647cd2d4723b9f5bf047e842fd6b00942ec9964ba3b291

2020.02.05 11:40:45 4: https://api.nibeuplink.com/api/v1/systems: HTTP response code 500
2020.02.05 11:40:45 5: HttpUtils https://api.nibeuplink.com/api/v1/systems: Got data, length: 164
2020.02.05 11:40:45 5: HttpUtils response header:
HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 164
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Feb 2020 10:40:44 GMT
Connection: close
2020.02.05 11:40:45 4: Nibe: Read callback: request type was update retry 1,
header: HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 164
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Feb 2020 10:40:44 GMT
Connection: close, body length 164
2020.02.05 11:40:45 5: Nibe: Read callback: body
{
  "httpStatusCode": 500,
  "errorCode": 0,
  "timestamp": "2020-02-05T10:40:45.4143015Z",
  "details": [
    "Internal Server Error"
  ],
  "data": null
}
2020.02.05 11:40:45 4: Nibe: Read found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.02.05 11:40:45 4: Nibe: Read is decoding the buffer as utf-8
2020.02.05 11:40:45 5: Nibe: JSON Flatter called : prefix , ref is HASH(0x5614b56a46b0)
2020.02.05 11:40:45 5: Nibe: JSON Flatter doing recursion because value is a ARRAY
2020.02.05 11:40:45 5: Nibe: JSON Flatter called : prefix details_, ref is ARRAY(0x5614ae368490)
2020.02.05 11:40:45 5: Nibe: JSON Flatter sets details_0 to Internal Server Error
2020.02.05 11:40:45 5: Nibe: JSON Flatter sets httpStatusCode to 500
2020.02.05 11:40:45 5: Nibe: JSON Flatter sets errorCode to 0
2020.02.05 11:40:45 5: Nibe: JSON Flatter sets timestamp to 2020-02-05T10:40:45.4143015Z
2020.02.05 11:40:45 4: Nibe: extracted JSON values to internal
2020.02.05 11:40:45 5: Nibe: GetCookies is looking for Cookies
2020.02.05 11:40:45 5: Nibe: ExtractSid called, context reading, num
2020.02.05 11:40:45 4: Nibe: checking for redirects, code=500, ignore=0
2020.02.05 11:40:45 4: Nibe: no redirects to handle
2020.02.05 11:40:45 5: Nibe: GetRegex found precompiled reAuthRegex for  as (?^:500.Internal.Server.Error|Unauthorized|default.backend...401)
2020.02.05 11:40:45 5: Nibe: Checking Auth with JSON message
2020.02.05 11:40:45 5: Nibe: CheckAuth is checking buffer with ReAuthRegex (?^:500.Internal.Server.Error|Unauthorized|default.backend...401)
2020.02.05 11:40:45 4: Nibe: CheckAuth decided new authentication required
2020.02.05 11:40:45 4: Nibe: Authentication still required but no retries left - did last authentication fail?
2020.02.05 11:40:45 5: Nibe: Read sets reading errorCode to value 0 of JSON errorCode
2020.02.05 11:40:45 5: Nibe: Read sets reading details_0 to value Internal Server Error of JSON details_0
2020.02.05 11:40:45 5: Nibe: Read sets reading timestamp to value 2020-02-05T10:40:45.4143015Z of JSON timestamp
2020.02.05 11:40:45 5: Nibe: Read sets reading httpStatusCode to value 500 of JSON httpStatusCode
2020.02.05 11:40:45 5: Nibe: Read starts parsing response to update with defined readings:
2020.02.05 11:40:45 4: Nibe: Read response matched 4, unmatch 0 Reading(s)
2020.02.05 11:40:45 5: Nibe: Read response to update matched errorCode details_0 timestamp httpStatusCode
2020.02.05 11:40:45 5: Nibe: HandleSendQueue called, qlen = 0


« Letzte Änderung: 05 Februar 2020, 11:52:26 von uwirt »
FHEM / Ubuntu / fitlet2
HomeMatic: CCU3|HmIP-STHD|HmIP-PCBS|HmIP-PCBS2|HmIP-PCBS-BAT|HM-WDC7000|HM-WDS100-C6-O|HM-WDS40|HM-LC-Sw1-FM|HM-LC-RGBW-WM|HM-ES-PMSw1-Pl|HM-ES-TX-WM
NAS: DS218+|DS209j|DS216+II|DS412+
Devices: Panasonic Webcams|Withings|Gardena Smart

Offline amenomade

  • Developer
  • Hero Member
  • ****
  • Beiträge: 7449
Antw:NIebe mittels HTTPMOD und API
« Antwort #3 am: 05 Februar 2020, 18:46:42 »
Also... Du kriegst mehrmals http 500 : Internal server error. Da kann nicht viel passieren wenn es schon bei der erste Request passiert.
Wahrscheinlich war der Server beim Versuch unverfügbar?

Anscheinend hast Du auch inzwischen die Definition geändert : du rufst zuerst https://api.nibeuplink.com/api/v1/systems, aber früher war ein deinem Define https://api.nibeuplink.com/api/v1/systems/29054/
Wo sind letzendlich die Daten, die Du brauchst?
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Offline herrmannj

  • Global Moderator
  • Hero Member
  • ****
  • Beiträge: 6148
Antw:NIebe mittels HTTPMOD und API
« Antwort #4 am: 05 Februar 2020, 19:58:25 »
Hallo,

wenn ich die api im browser aufrufe dann bekomme ich keinen status 500 sondern ein json und 200(ok). Der json ist leer.

Ich vermute daher dass der cookie oder die Art des Auth dem Server Probleme bereiten. Wo ist die api denn beschrieben ?

vg
Joerg
smartVisu mit fronthem, einiges an HM, RFXTRX, Oregon, CUL, Homeeasy, ganz viele LED + Diverse

Offline uwirt

  • Full Member
  • ***
  • Beiträge: 237
  • "I'm sorry, Dave. I'm afraid I can't do that."
Antw:NIebe mittels HTTPMOD und API
« Antwort #5 am: 07 Februar 2020, 11:03:47 »
Die Dokumentation der NIBE Uplink AP ist leider nur über ein Login mit User ID und Passwort erreichbar. Hier ein paar Auszüge:

Zitat
Authentication
For a client to be allowed to communicate with the NIBE Uplink API it needs to be registered with NIBE Uplink. When registering a client a client key and a client secret are generated and supplied to the client owner. It is up to the client owner to make sure these are not leaked to a third party. If the client owner suspects the client key and secret could have been leaked, it is the client owner's responsibility to notify the NIBE Uplink team about the potential leak in order to block any malicious activity done in the name of their client.
User Authentication
Currently, all requests to the NIBE Uplink API requires a valid user authentication. The user authentication makes sure that the client can only access the resources for that particular user.
Users are authenticated via the OAuth 2 protocol. NIBE Uplink currently supports the Authorization Code Grant flow and the Implicit Grant flow. The Authorization Code Grant flow targets clients which the OAuth 2 specification deems confidential, such as web applications and mobile apps while the Implicit Grant flow is a shorter flow which targets public clients that can't keep the confidentiality of the OAuth credentials, such as browser based JavaScript applications.
Under no circumstances is the client allowed to process or handle a user's secret login credentials.
The following URL:s are used for the OAuth 2 requests
Authorize endpoint https://api.nibeuplink.com/oauth/authorize
Token endpoint https://api.nibeuplink.com/oauth/token

Ich habe wie weiter oben beschrieben meine Definition basierend auf dem Modell der Miele API aufgebaut. Wenn ich es recht interpretiere geschieht das ganz in folgenden Schritten:

1. Voraussetzung ist dass ich mich mittels Benutzername und Passwort bei der Nibe API mein Konto registriert habe, dort eine dann eine "redirect_uri" hinterlege und danach eine "client_ID" und ein "client_secret" zugeordnet erhalte. Mittels client_ID und client_secret erhält man danach den temporären "access_token".

2. Die Abfrage der Daten erfolgt mit einem Haupt-Request:https://api.nibeuplink.com/api/v1/systems/29054/ alle 60 Sekunden

3. falls der access_token verfallen ist (das versuche ich mit dem reAuthRegex 500.Internal.Server.Error|Unauthorized|default.backend...401 abzufangen) wird ein neuer Token verlangt - das sollten dann sid2URL und sid3URL erledigen.

... und ja ...

Zitat
Anscheinend hast Du auch inzwischen die Definition geändert : du rufst zuerst https://api.nibeuplink.com/api/v1/systems, aber früher war ein deinem Define https://api.nibeuplink.com/api/v1/systems/29054/
Wo sind letzendlich die Daten, die Du brauchst?

Ich bin halt noch am ausprobieren. Die Daten sind unter der {systemUnitId} 29054 erhältlich (GET api/v1/systems/{systemId})

Vermutlich stimmt schon beim Haupt-Request etwas nicht. Muss ich dort den Token mitschicken oder meine ID's?
FHEM / Ubuntu / fitlet2
HomeMatic: CCU3|HmIP-STHD|HmIP-PCBS|HmIP-PCBS2|HmIP-PCBS-BAT|HM-WDC7000|HM-WDS100-C6-O|HM-WDS40|HM-LC-Sw1-FM|HM-LC-RGBW-WM|HM-ES-PMSw1-Pl|HM-ES-TX-WM
NAS: DS218+|DS209j|DS216+II|DS412+
Devices: Panasonic Webcams|Withings|Gardena Smart

Offline uwirt

  • Full Member
  • ***
  • Beiträge: 237
  • "I'm sorry, Dave. I'm afraid I can't do that."
Antw:Nibe mittels HTTPMOD und API
« Antwort #6 am: 16 März 2020, 10:40:07 »
Ich habe das jetzt anders hingekriegt. Ich konnte auf dem Netz ein JavaScript finden und anpassen, welches mir über Crontab regelmässig die Daten von Nibeuplink in eine json-Datei schreibt. Diese Datei wird dann über HTTPMOD in FEHM eingelesen.
FHEM / Ubuntu / fitlet2
HomeMatic: CCU3|HmIP-STHD|HmIP-PCBS|HmIP-PCBS2|HmIP-PCBS-BAT|HM-WDC7000|HM-WDS100-C6-O|HM-WDS40|HM-LC-Sw1-FM|HM-LC-RGBW-WM|HM-ES-PMSw1-Pl|HM-ES-TX-WM
NAS: DS218+|DS209j|DS216+II|DS412+
Devices: Panasonic Webcams|Withings|Gardena Smart

Offline herrmannj

  • Global Moderator
  • Hero Member
  • ****
  • Beiträge: 6148
Antw:Nibe mittels HTTPMOD und API
« Antwort #7 am: 16 März 2020, 10:47:36 »
Kannst du das js bitte kurz verlinken?
smartVisu mit fronthem, einiges an HM, RFXTRX, Oregon, CUL, Homeeasy, ganz viele LED + Diverse

Offline Mad-at

  • Full Member
  • ***
  • Beiträge: 120
Antw:Nibe mittels HTTPMOD und API
« Antwort #8 am: 25 April 2020, 15:31:50 »
Bastle gerade selber am gleichen Problem. Ich vermute er hat die gleiche unbekannte Quelle wie das hier verwendet: https://github.com/sebilm/ioBroker.nibeuplink
Vielleicht hilft das jemand anderem weiter.

Edit: hier gibt es ein php script dass in json schreibt: https://www.symcon.de/forum/threads/25663-Heizung-Nibe-F750-Nibe-Uplink-auslesen-auswerten
« Letzte Änderung: 25 April 2020, 16:59:56 von Mad-at »

Offline amenomade

  • Developer
  • Hero Member
  • ****
  • Beiträge: 7449
Antw:Nibe mittels HTTPMOD und API
« Antwort #9 am: 25 April 2020, 18:18:25 »
Das ist noch simpler als die API mit OAuth2. Er geht einfach über die offentliche Webseite (URL in Def oder getXXURL), und mach ein POST der Login Daten (sid01URL und sid01Data) zur Anmeldung.
Mit enableCookies und evtl. ein paar requestXXHeaders sollte es funktionieren.

Es sei denn, das hat sich mittlerweile geändert. Der PHP Script ist ja von 2016
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Offline andy19850

  • Jr. Member
  • **
  • Beiträge: 95
Antw:Nibe mittels HTTPMOD und API
« Antwort #10 am: 26 Mai 2020, 12:13:05 »
Hier wäre ich auch sehr an einer Lösung interessiert. Das PHP-Script bekomme ich irgendwie nicht zum laufen. Meine Fähigkeiten an der Stelle sind aber auch sehr limitiert :(

Der betr. Header-Teil der per HTTPMOD ankommt sollte doch dieser sein, oder?

<a id="Content"></a>

      <div id="EmilCleanContent" style="position:relative;height:610px;width:100%;">


        <div class="splash_bg splash_bg1">
         


<div class="splash_box small">
<div class="LoginBoxVertical">
<form action="/LogIn" method="post">    <div style="height:35px;">
     
    </div>
      <fieldset>
        <legend>Account Information</legend>
        <input id="returnUrl" name="returnUrl" type="hidden" value="/System/xxxxxx/Status/ServiceInfo" />
        <div style="width: 225px; margin: 0;">
          <label for="Email">E-mail</label><br />
          <input autocomplete="off" class="LoginTextbox input_trim" data-val="true" data-val-regex="Not a valid e-mail" data-val-regex-pattern="^[\S]+@[\S]+\.[\w]{2,}$" data-val-required="E-mail is required" id="Email" name="Email" tabindex="1" type="email" value="" />
        </div>
        <div style="width: 225px; margin: 0;">
          <label for="Password">Password</label> (<a href="/ResetPassword">Lost password</a>)<br />
          <input autocomplete="off" class="LoginTextbox" data-val="true" data-val-required="Password is required" id="Password" name="Password" tabindex="2" type="password" />
        </div>
        <div style="margin-top: 13px;text-align: left;">
          <input type="submit" class="LoginButton green" value="Log in" tabindex="3" />
          <a href="/Register">Register an account</a>
        </div>
      </fieldset>
</form>  <p style="text-align: center;">
    <br />
  </p>
</div>
</div>
        </div>
      </div>

Wie gebe ich nun Nutzer und PW mit?
« Letzte Änderung: 26 Mai 2020, 12:47:11 von andy19850 »

Offline amenomade

  • Developer
  • Hero Member
  • ****
  • Beiträge: 7449
Antw:Nibe mittels HTTPMOD und API
« Antwort #11 am: 26 Mai 2020, 22:58:21 »
Wie hier gesagt. https://forum.fhem.de/index.php/topic,108102.msg1046946.html#msg1046946

Da musst Du im Browser gucken (mit F12 / Reiter Netzwerk) wie und wo die Daten gepostet werden.

sid01Data ist wahrscheinlich etwas in der Art: Email=<email>&Password=<Passwort>
« Letzte Änderung: 26 Mai 2020, 23:03:36 von amenomade »
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Offline jupp

  • Newbie
  • Beiträge: 1
Antw:Nibe mittels HTTPMOD und API
« Antwort #12 am: 01 April 2021, 14:28:05 »
Habe soeben erst Eure Fragen gesehen. Ich habe die Abfrage der Daten über Nibe Uplink mittels PHP Script und HTTPMOD jetzt seit geraumer Zeit stehen.

Vielleicht kann es ja noch jemand einsetzen:

Das PHP Script sieht wie folgt aus:

<?php
/* 
 * read nibe heatpump values from nibeuplink status web page and return them in json format. 
 * based on: https://www.symcon.de/forum/threads/25663-Heizung-Nibe-F750-Nibe-Uplink-auslesen-auswerten 
 * to get the code which is required as parameter, log into nibe uplink, open status page of your heatpump, and check url: 
 * https://www.nibeuplink.com/System/<code>/Status/Overview 
 * 
 * usage: nibe.php?email=<email>&password=<password>&code=<code> 
 */ 
function umlaute_ersetzen($text){

$such_array  = array ('ä''ö''ü''ß''°''Ä''Ö''Ü');

$ersetzen_array = array ('ae''oe''ue''ss''''Ae''Oe''Ue');

$neuer_text  str_replace($such_array$ersetzen_array$text);

return 
$neuer_text;

}
// to add additional debug output to the resulting page: 
$debug false

// Create temp file to store cookies 
$ckfile tempnam ("/tmp""CURLCOOKIE"); 

// URL to login page 
$url "https://www.nibeuplink.com/LogIn"

// Get Login page and its cookies and save cookies in the temp file 
$ch curl_init(); 
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse); // Accepts all CAs 
curl_setopt($chCURLOPT_URL$url); 
curl_setopt($chCURLOPT_COOKIEJAR$ckfile); // Stores cookies in the temp file 
curl_setopt($chCURLOPT_RETURNTRANSFERtrue); 
$output curl_exec($ch); 
// Now you have the cookie, you can POST login values 
$ch curl_init(); 
curl_setopt($chCURLOPT_SSL_VERIFYPEER0); 
curl_setopt($chCURLOPT_SSL_VERIFYHOST0); 
curl_setopt($chCURLOPT_URL$url); 
curl_setopt($chCURLOPT_POST2); 
//curl_setopt($ch, CURLOPT_POSTFIELDS, "Email=".$_GET['email']."&Password=".$_GET['password']); 
curl_setopt($chCURLOPT_POSTFIELDS"Email=***@***.de&Password=********"); 
curl_setopt($chCURLOPT_COOKIEFILE$ckfile); // Uses cookies from the temp file 
curl_setopt($chCURLOPT_RETURNTRANSFERtrue); 
curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue); // Tells cURL to follow redirects 
$output curl_exec($ch); 

//curl_setopt($ch, CURLOPT_URL, "https://www.nibeuplink.com/System/".$_GET['code']."/Status/ServiceInfo"); 
curl_setopt($chCURLOPT_URL"https://www.nibeuplink.com/System/123456/Status/ServiceInfo"); 
curl_setopt($chCURLOPT_COOKIEFILE$ckfile); 
curl_setopt($chCURLOPT_POST0); 
$result curl_exec($ch);
$result umlaute_ersetzen($result);

$pattern '/<h3>(.*?)<\/h3>\s*<table[^>]*>.+?<tbody>(.+?)<\/tbody>\s*<\/table>/s'
if (
$debug) echo "pattern: <xmp>".$pattern."</xmp><br>"

$pattern2 '/<tr>\s*<td>(.+?)<span[^>]*>[^<]*<\/span>\s*<\/td>\s*<td>\s*<span[^>]*>([^<]*)<\/span>\s*<\/td>\s*<\/tr>/s'
if (
$debug) echo "pattern2: <xmp>".$pattern2."</xmp><br>"

preg_match_all($pattern$result$matches);
//$matches = json_encode($matches);
$matches umlaute_ersetzen($matches);
//$matches = htmlentities($matches);

// build json format from matches 
echo '{';
$first true
foreach (
$matches[1] as $i => $title) { 
$title umlaute_ersetzen($title);
        echo (
$first '"' ',"').trim($title).'":{';
        
$content $matches[2][$i];
        
preg_match_all($pattern2$content$values);
        
$nestedFirst true;
        foreach (
$values[1] as $j => $field) {
$field umlaute_ersetzen($field);
                echo (
$nestedFirst '"' ',"').trim($field).'":"'.$values[2][$j].'"';
                
$nestedFirst false;
        }
        echo 
"}";
        
$first false

echo 
"}";

if (
$debug) { 
        echo 
"<pre><xmp>"
        echo 
print_r($matches); 
        echo 
"<br><br>"
        echo 
$result
        echo 
"</xmp></pre>"

?>


Email und Passwort müsst Ihr natürlich Eurem Zugang anpassen.

Außerdem https://www.nibeuplink.com/System/123456/Status/ServiceInfo den Code Eurer Wärmepumpe (123456) anpassen. Nach der Anmeldung auf der Uplink Seite ist der in der URL zu finden.

Beim Aufruf des PHP Files solltet Ihr die Daten Eurer Wärmepumpe angezeigt bekommen.

Die lese ich dann über HTTPMOD in Readings per Regexp:

Rawdef:

defmod NibeUplink HTTPMOD http://Pfad_zur_Datei/nibe.php 120
attr NibeUplink alias NibeUplink
attr NibeUplink get01Encode UTF-8
attr NibeUplink get01Name UplinkDaten
attr NibeUplink getHeader1 Content-Type: application/json
attr NibeUplink getHeader2 Accept: */*
attr NibeUplink getURL http://Pfad_zur_Datei/nibe.php
attr NibeUplink reading01Encode UTF-8
attr NibeUplink reading01JSON modes
attr NibeUplink reading1Name Aussentemperatur
attr NibeUplink reading1Regex Aussentemperatur":"([\d\.]+)
attr NibeUplink reading2Name Brauchwasserbereitung
attr NibeUplink reading2Regex Brauchwasserbereitung":"([\d\.]+)
attr NibeUplink reading3Name Ruecklauftemp
attr NibeUplink reading3Regex Ruecklauftemp.":"([\d\.]+)
attr NibeUplink reading4Name Vorlauftemp
attr NibeUplink reading4Regex Vorlauftemp.":"([\d\.]+)
attr NibeUplink reading5Name Leistung_ZH
attr NibeUplink reading5Regex Leistung der elektrischen ZH":"([\d\.]+)
attr NibeUplink reading6Name WM_zaehler_inkl_ZH
attr NibeUplink reading6Regex BW, inkl. int. ZH":"([\d\.]+)
attr NibeUplink reading7Name WM_zaehler_nur_Verd
attr NibeUplink reading7Regex BW, nur Verd.":"([\d\.]+)
attr NibeUplink reading8Name WM_zaehler_inkl. ZH
attr NibeUplink reading8Regex Waerme, inkl. int. Zusatz":"([\d\.]+)
attr NibeUplink room Heizungskeller
attr NibeUplink timeout 20

Im HTTPOD Device muß natürlich das Attribut getURL angepasst werden an den Pfad, wo die php Datei gespeichert ist.

Vielleicht hilft es Jemanden weiter.