HTTPMOD unerwartetes Ergebnis / Comexio Anbindung Onewire Fühler

Begonnen von Oli_t, 16 August 2019, 10:39:49

Vorheriges Thema - Nächstes Thema

Oli_t

Hallo,

ich möchte gerne einen Wert aus einem anderen Server per HTTP auslesen. Dazu habe ich mir ein Gerät "Aussentemperatur" per HTTPMOD erstellt:


Internals:
   BUSY       0
   CFGFN     
   DEF        https://*******@192.168.0.35/api/?action=get&onewire=OT5 60
   FUUID      5d5641c0-f33f-c6cc-fbef-53883a93958371db
   Interval   60
   LASTSEND   1565943915.88193
   MainURL    https://*******@192.168.0.35/api/?action=get&onewire=OT5
   ModuleVersion 3.5.9 - 13.2.2019
   NAME       Aussentemperatur
   NOTIFYDEV  global
   NR         11434
   NTFY_ORDER 50-Aussentemperatur
   STATE      0
   TRIGGERTIME 1565943975.87433
   TRIGGERTIME_FMT 2019-08-16 10:26:15
   TYPE       HTTPMOD
   addr       https://192.168.0.35:443
   auth       1
   buf       
   code       200
   compress   1
   conn       
   data       
   displayurl https://*******@192.168.0.35/api/?action=get&onewire=OT5
   header     
   host       192.168.0.35
   httpbody   14.31
   httpheader HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Pragma: no-cache
Content-Type: text/plain; charset=utf-8
Content-Length: 6
Connection: close
Date: Fri, 16 Aug 2019 08:17:59 GMT
Server: comexio
   httpversion 1.1
   hu_blocking 0
   hu_filecount 90
   hu_port    443
   hu_portSfx
   ignoreredirects 0
   loglevel   4
   path       /api/?action=get&onewire=OT5
   protocol   https
   pwd        *******
   redirects  0
   timeout    2
   url        https://*******@192.168.0.35/api/?action=get&onewire=OT5
   user       *******
   value      0
   QUEUE:
   READINGS:
     2019-08-16 10:25:17   LAST_ERROR     
     2019-08-16 10:25:17   LAST_REQUEST    update
     2019-08-16 10:17:56   MATCHED_READINGS temp
     2019-08-16 10:17:56   UNMATCHED_READINGS
     2019-08-16 10:17:56   temp            HTTP/1.1 200 OK
   REQUEST:
     data       
     header     
     ignoreredirects 0
     retryCount 0
     type       update
     url        https://*******@192.168.0.35/api/?action=get&onewire=OT5
     value      0
   defptr:
     readingBase:
       temp       reading
     readingNum:
       temp       01
     readingOutdated:
     requestReadings:
       update:
         temp       reading 01
   sslargs:
Attributes:
   enableControlSet 1
   httpVersion 1.1
   reading01Name temp
   reading01Regex (.*)
   showBody   1
   showError  1
   showMatched 1
   userattr   reading01Name reading01Regex


Als Regex habe ich (.*) eingetragen. Scheinbar habe ich da zu einfach gedacht: Es kommt dann nämlich nur "HTTP/1.1 200 OK" als Wert zurück. Wenn ich in den "httpbody" gucke, steht da aber der Wert, den ich eigentlich gerne hätte. Was mache ich falsch ? Dieses Gerät liefert wirklich nur den Wert als Antwort zurück. Kann es daran liegen ? Fehlen HTTPMOD die HTTP-Header ?

Viele Grüße,

Oli

frank

ändere die regex auf "(?s)(.*)" und zeige, was im reading temp steht.
FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

Oli_t

Hallo Frank,
leider findet er dann gar keinen Match. Das Reading bleibt leer und im Log kommt: "Aussentemperatur: Read response to update didn't match any Reading". Spasseshalber habe ich die URL mal mit curl angefunkt: wie erwartet kommt da der richtige Wert zurück  ::)

frank

FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

Oli_t

Ah, ich Dummerchen natürlich !  :-[


temp


HTTP/1.1 200 OK
Set-Cookie: comexio_session_id=gnsbtfi3qdtu0ilfjejs39u804; expires=Fri, 23-Aug-2019 15:23:26 GMT; path=/
Set-Cookie: comexio_session_id=gnsbtfi3qdtu0ilfjejs39u804; expires=Fri, 23-Aug-2019 15:23:26 GMT; path=/
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Pragma: no-cache
Content-Type: text/plain; charset=utf-8
X-Powered-By: COMEXIO
Content-Length: 7
Connection: close
Date: Fri, 16 Aug 2019 15:23:26 GMT
Server: comexio

19.875


Da merkt man, dass ich noch nicht oft mit Regex zu tun hatte  ;D
Wie bekomme ich jetzt den "Vorspann" weg ?

frank

FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

Oli_t

Leider findet er dann Nichts. Auch ohne Anführungszeichen  ;)

frank

ok, 2 versuch. :)
(?s).*?([0-9.]+)$
FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

Oli_t

Nö, kann er auch nicht matchen. Kann man den Header nicht einfach abschneiden?

frank

und dies?
(?s)([0-9.]+)$

Zitatabschneiden
du meinst alles einsammeln und im 2. schritt den string kürzen?
geht auch, aber es muss auch mit regex funktionieren.  ;)
FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

Oli_t


frank

seltsam. zeig noch mal ein list.
FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

Oli_t



Internals:
   BUSY       0
   CFGFN     
   DEF        https://*******@192.168.0.35/api/?action=get&onewire=OT5 30
   FUUID      5d56c685-f33f-07f4-a156-abeb89e82df9479c
   Interval   30
   LASTSEND   1565975137.66192
   MainURL    https://*******@192.168.0.35/api/?action=get&onewire=OT5
   ModuleVersion 3.5.9 - 13.2.2019
   NAME       Aussentemperatur
   NOTIFYDEV  global
   NR         3536
   NTFY_ORDER 50-Aussentemperatur
   STATE      ???
   TRIGGERTIME 1565975167.66073
   TRIGGERTIME_FMT 2019-08-16 19:06:07
   TYPE       HTTPMOD
   addr       https://192.168.0.35:443
   auth       1
   buf       
   code       200
   compress   1
   conn       
   data       
   displayurl https://*******@192.168.0.35/api/?action=get&onewire=OT5
   header     
   host       192.168.0.35
   httpbody   18.437
   httpheader HTTP/1.1 200 OK
Set-Cookie: comexio_session_id=dao3ukvgdeupki4a47bl0aehm5; expires=Fri, 23-Aug-2019 17:05:40 GMT; path=/
Set-Cookie: comexio_session_id=dao3ukvgdeupki4a47bl0aehm5; expires=Fri, 23-Aug-2019 17:05:40 GMT; path=/
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Pragma: no-cache
Content-Type: text/plain; charset=utf-8
X-Powered-By: COMEXIO
Content-Length: 7
Connection: close
Date: Fri, 16 Aug 2019 17:05:40 GMT
Server: comexio
   httpversion 1.1
   hu_blocking 0
   hu_filecount 163
   hu_port    443
   hu_portSfx
   ignoreredirects 0
   loglevel   4
   path       /api/?action=get&onewire=OT5
   protocol   https
   pwd        *******
   redirects  0
   timeout    2
   url        https://*******@192.168.0.35/api/?action=get&onewire=OT5
   user       *******
   value      0
   QUEUE:
   READINGS:
     2019-08-16 19:04:42   LAST_ERROR      https://*******@192.168.0.35/api/?action=get&onewire=OT5: Can't connect(2) to https://192.168.0.35:443:  SSL wants a read first
     2019-08-16 19:05:39   LAST_REQUEST    update
     2019-08-16 19:05:39   MATCHED_READINGS
     2019-08-16 19:05:39   UNMATCHED_READINGS temp
     2019-08-16 19:00:12   temp            1
   REQUEST:
     data       
     header     
     ignoreredirects 0
     retryCount 0
     type       update
     url        https://*******@192.168.0.35/api/?action=get&onewire=OT5
     value      0
   defptr:
     readingBase:
       temp       reading
     readingNum:
       temp       01
     readingOutdated:
     requestReadings:
       update:
         temp       reading 01
   sslargs:
Attributes:
   enableControlSet 1
   httpVersion 1.1
   reading01Name temp
   reading01Regex (?s)([0-9.]+)$
   showBody   1
   showError  1
   showMatched 1
   userattr   reading01Name reading01Regex



frank

FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

Oli_t

Das Obere funktioniert !   ;D
Krass ! Wie findet man Sowas ?