FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: Thoffi1978 am 26 Dezember 2020, 12:08:27

Titel: [gelöst] Regex wird nicht immer ausgelesen
Beitrag von: Thoffi1978 am 26 Dezember 2020, 12:08:27
Hallo,
bis jetzt dachte ich ich hätte ein falschen reading01Regex.
Das scheint aber nur zum Teil zu stimmen wie ich gesehen habe.

Ich habe bis vor kurzem die Temperatur aus meiner Mobotix Kamera ausgelsen.
Seit kurzem funktioniert das nicht mehr regelmäßig.
Ich habe im LOG gesehen, dass zwischendurch doch die Daten korrekt ausgelesen wurden.

Könnt Ihr mir sagen warum das mal geht und mal nicht.

Logfile:
2020.12.26 12:03:32 4: Temperatur: GetUpdate called (update)
2020.12.26 12:03:32 4: Temperatur: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 120.0 sec at 2020-12-26 12:05:32, interval 120
2020.12.26 12:03:32 5: Temperatur: AddToQueue adds type update to URL http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), no data, no headers, retry 0, initial queue len: 0
2020.12.26 12:03:32 5: Temperatur: HandleSendQueue called from AddToSendQueue, qlen = 1
2020.12.26 12:03:32 4: Temperatur: HandleSendQueue sends update with timeout 10 to http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), No Data, No Header
2020.12.26 12:03:33 5: Temperatur: ReadCallback called from __ANON__
2020.12.26 12:03:33 4: Temperatur: Read callback: request type was update retry 0,
header: HTTP/1.0 200 OK
Content-type: text/plain; charset=utf-8, body length 5
2020.12.26 12:03:33 5: Temperatur: Read callback: body
- 0.2
2020.12.26 12:03:33 4: Temperatur: BodyDecode found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.12.26 12:03:33 4: Temperatur: BodyDecode is decoding the response body as utf-8
2020.12.26 12:03:33 5: Temperatur: GetCookies is looking for Cookies
2020.12.26 12:03:33 5: Temperatur: ExtractSid called, context reading, num 0
2020.12.26 12:03:33 4: Temperatur: checking for redirects, code=200, ignore=0
2020.12.26 12:03:33 4: Temperatur: no redirects to handle
2020.12.26 12:03:33 5: Temperatur: Read callback sets LAST_REQUEST to update
2020.12.26 12:03:33 5: Temperatur: CheckAuth decided no authentication required
2020.12.26 12:03:33 5: Temperatur: Read starts parsing response to update with defined readings: 01
2020.12.26 12:03:33 5: Temperatur: ExtractReading state with regex /(?^:\n\s*([-+]?[\d\.]+))/...
2020.12.26 12:03:33 5: Temperatur: ExtractReading state did not match
2020.12.26 12:03:33 4: Temperatur: Read response to update didn't match any Reading
2020.12.26 12:03:33 5: Temperatur: HandleSendQueue called from ReadCallback, qlen = 0
2020.12.26 12:03:33 5: Temperatur: HandleSendQueue found no usable entry in queue


List Temperatur:
Internals:
   .LASTSEND  1608980732.48778
   .LastUpdate 1608980732.48281
   .TRIGGERTIME 1608980852.48281
   .getList   
   .setList   interval reread:noArg stop:noArg start:noArg clearCookies:noArg upgradeAttributes:noArg storeKeyValue
   .updateRequestHash 1
   BUSY       0
   DEF        http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS) 120
   FUUID      5f6b88ec-f33f-7e98-8cad-ca7470639ca5faf7
   Interval   120
   MainURL    http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS)
   ModuleVersion 4.0.16 - 5.12.2020
   NAME       Temperatur
   NOTIFYDEV  global
   NR         451
   NTFY_ORDER 50-Temperatur
   STATE      +10.6
   TYPE       HTTPMOD
   value     
   .attraggr:
   .attrminint:
   .readingParseList:
     01
   CompiledRegexes:
   HttpUtils:
     NAME       
     addr       http://192.168.2.12:80
     auth       1
     code       200
     compress   1
     conn       
     data       
     displayurl http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS)
     header     
     host       192.168.2.12
     httpheader HTTP/1.0 200 OK
Content-type: text/plain; charset=utf-8
     httpversion 1.0
     hu_blocking 0
     hu_filecount 1
     hu_port    80
     hu_portSfx
     ignoreredirects 1
     loglevel   4
     path       /control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS)
     protocol   http
     pwd        fhem1234
     redirects  0
     timeout    10
     url        http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS)
     user       Fhem
     sslargs:
   QUEUE:
   READINGS:
     2020-12-25 11:37:27   state           +10.6
   REQUEST:
     context    reading
     data       
     header     
     ignoreredirects 0
     num        0
     retryCount 0
     type       update
     url        http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS)
   defptr:
     readingBase:
       state      reading
     readingNum:
       state      01
     readingOutdated:
     requestReadings:
       update:
         state      reading 01
Attributes:
   reading01Name state
   reading01Regex \n\s*([-+]?[\d\.]+)
   room       Haus
   timeout    10
   verbose    5


FileLog:
2020-12-22_21:33:18 Temperatur +10.0
2020-12-22_21:35:18 Temperatur +10.0
2020-12-22_21:37:17 Temperatur +10.0
2020-12-22_21:39:18 Temperatur +10.0
2020-12-22_21:41:18 Temperatur +10.0
2020-12-22_21:43:18 Temperatur +10.0
2020-12-25_11:01:27 Temperatur +10.0
2020-12-25_11:03:27 Temperatur +10.2
2020-12-25_11:05:27 Temperatur +11.8
2020-12-25_11:07:27 Temperatur +11.8
2020-12-25_11:09:27 Temperatur +12.6
2020-12-25_11:11:27 Temperatur +13.7
2020-12-25_11:13:27 Temperatur +13.7
2020-12-25_11:15:27 Temperatur +13.7
2020-12-25_11:17:27 Temperatur +13.7
2020-12-25_11:19:27 Temperatur +13.7
2020-12-25_11:21:27 Temperatur +13.7
2020-12-25_11:23:27 Temperatur +13.7
2020-12-25_11:25:27 Temperatur +12.4
2020-12-25_11:27:27 Temperatur +11.8
2020-12-25_11:29:27 Temperatur +11.8
2020-12-25_11:31:27 Temperatur +11.8
2020-12-25_11:33:27 Temperatur +11.8
2020-12-25_11:35:27 Temperatur +11.8
2020-12-25_11:37:27 Temperatur +10.6


Vielen Dank,
Hoffi
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: amenomade am 27 Dezember 2020, 00:12:26
Weil bei den negativen Werten anscheinend ein Leerzeichen nach dem Minus kommt.
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: Thoffi1978 am 28 Dezember 2020, 08:47:03
Hallo amenomade,

ganz so einfach ist doch wohl doch nicht. Auch bei Plusgraden wird der REGEX nicht immer übergeben.
Wenn ich den Link im Explorer eingebe, antwortet die Kamera korrekt.
Auch wenn das Leerzeichen evtl. mit übergeben wird, wie kann es sein das mal übermittelt wird?
Gibt es ein "besseren" reading01Regex als \n\s*([-+]?[\d\.]+)


2020.12.28 08:43:37 4 : Temperatur: GetUpdate called (update)
2020.12.28 08:43:37 4 : Temperatur: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 120.0 sec at 2020-12-28 08:45:37, interval 120
2020.12.28 08:43:37 5 : Temperatur: AddToQueue adds type update to URL http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), no data, no headers, retry 0, initial queue len: 0
2020.12.28 08:43:37 5 : Temperatur: HandleSendQueue called from AddToSendQueue, qlen = 1
2020.12.28 08:43:37 4 : Temperatur: HandleSendQueue sends update with timeout 10 to http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), No Data, No Header
2020.12.28 08:43:38 5 : Temperatur: ReadCallback called from __ANON__
2020.12.28 08:43:38 4 : Temperatur: BodyDecode found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.12.28 08:43:38 4 : Temperatur: BodyDecode is decoding the response body as utf-8
2020.12.28 08:43:38 5 : Temperatur: GetCookies is looking for Cookies
2020.12.28 08:43:38 5 : Temperatur: ExtractSid called, context reading, num 0
2020.12.28 08:43:38 4 : Temperatur: checking for redirects, code=200, ignore=0
2020.12.28 08:43:38 4 : Temperatur: no redirects to handle
2020.12.28 08:43:38 5 : Temperatur: Read callback sets LAST_REQUEST to update
2020.12.28 08:43:38 5 : Temperatur: CheckAuth decided no authentication required
2020.12.28 08:43:38 5 : Temperatur: Read starts parsing response to update with defined readings: 01
2020.12.28 08:43:38 5 : Temperatur: ExtractReading state with regex /(?^:\n\s*([-+]?[\d\.]+))/...
2020.12.28 08:43:38 5 : Temperatur: ExtractReading state did not match
2020.12.28 08:43:38 4 : Temperatur: Read response to update didn't match any Reading
2020.12.28 08:43:38 5 : Temperatur: HandleSendQueue called from ReadCallback, qlen = 0
2020.12.28 08:43:38 5 : Temperatur: HandleSendQueue found no usable entry in queue
2020.12.28 08:43:38 4 : Temperatur: Read callback: request type was update retry 0, header: HTTP/1.0 200 OK Content-type: text/plain; charset=utf-8, body length 5
2020.12.28 08:43:38 5 : Temperatur: Read callback: body + 1.6
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: amenomade am 28 Dezember 2020, 10:33:42
Ich würde einfach mit
([-+ ]*[\d\.]+)
probieren

Wenn es nicht geht, bitte die Log mit verbose 5 zeigen.
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: Thoffi1978 am 28 Dezember 2020, 11:37:08
Das klappt leider auch nicht.
Jetzt bekomme ich den Wert "1" ausgegeben.

Bei Abfrage über die Explorer wird "+ 1.6" angezeigt.

2020.12.28 11:33:37 4 : Temperatur: GetUpdate called (update)
2020.12.28 11:33:37 4 : Temperatur: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 120.0 sec at 2020-12-28 11:35:37, interval 120
2020.12.28 11:33:37 5 : Temperatur: AddToQueue adds type update to URL http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), no data, no headers, retry 0, initial queue len: 0
2020.12.28 11:33:37 5 : Temperatur: HandleSendQueue called from AddToSendQueue, qlen = 1
2020.12.28 11:33:37 4 : Temperatur: HandleSendQueue sends update with timeout 10 to http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), No Data, No Header
2020.12.28 11:33:38 5 : Temperatur: ReadCallback called from __ANON__
2020.12.28 11:33:38 4 : Temperatur: BodyDecode found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.12.28 11:33:38 4 : Temperatur: BodyDecode is decoding the response body as utf-8
2020.12.28 11:33:38 5 : Temperatur: GetCookies is looking for Cookies
2020.12.28 11:33:38 5 : Temperatur: ExtractSid called, context reading, num 0
2020.12.28 11:33:38 4 : Temperatur: checking for redirects, code=200, ignore=0
2020.12.28 11:33:38 4 : Temperatur: no redirects to handle
2020.12.28 11:33:38 5 : Temperatur: Read callback sets LAST_REQUEST to update
2020.12.28 11:33:38 5 : Temperatur: CheckAuth decided no authentication required
2020.12.28 11:33:38 5 : Temperatur: Read starts parsing response to update with defined readings: 01
2020.12.28 11:33:38 5 : Temperatur: ExtractReading state with regex /(?^:([-+ ]*[\d\.]+))/...
2020.12.28 11:33:38 5 : Temperatur: ExtractReading for reading01-1 sets state to 1.0
2020.12.28 11:33:38 5 : Temperatur: ExtractReading value as hex is 312e30
2020.12.28 11:33:38 4 : Temperatur: Read response matched 1, unmatch 0 Reading(s)
2020.12.28 11:33:38 5 : Temperatur: Read response to update matched state
2020.12.28 11:33:38 5 : Temperatur: HandleSendQueue called from ReadCallback, qlen = 0
2020.12.28 11:33:38 5 : Temperatur: HandleSendQueue found no usable entry in queue
2020.12.28 11:33:38 4 : Temperatur: Read callback: request type was update retry 0, header: HTTP/1.0 200 OK Content-type: text/plain; charset=utf-8, body length 5
2020.12.28 11:33:38 5 : Temperatur: Read callback: body + 1.6</div>2020-12-28 11:33:38 HTTPMOD Temperatur 1.0
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: amenomade am 28 Dezember 2020, 14:41:59
ZitatBei Abfrage über die Explorer wird "+ 1.6" angezeigt.

Kannst Du mit Rechklick in der Expkorer Seite den ganzen Quellcode der Seite  schauen und hier in Code Tags kopieren?

Ich vermute, der parst etwas wie "HTTP/1.0"
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: Thoffi1978 am 29 Dezember 2020, 08:40:54
Hallo,
mit der rechten Maustaste wird mir nicht das angezeigt wie ich es erwartet hätte.
Anbei ein Foto, das ist die Seiteninformation.
mit rechter Maustaste Quelltext anzeigen wird einfach nur
+ 1.6
angezeigt

Hoffi
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: amenomade am 29 Dezember 2020, 11:30:45
Komisch. Er hat aber doch ein Header:
Zitatheader HTTP/1.0 200 OK Content-type: text/plain; charset=utf-8, body length 5
Dies sollte im Quelltext erscheinen.

Und er hat auch zusätzliche Sachen im body:
Zitatbody + 1.6</div>
Wo ist denn der <div> Tag, und wo kommt der </div> Tag her?

Aber gut. Wir probieren blind. Entweder:
(^[-+ ]*[\d\.]+)
oder
<div>([-+ ]*[\d\.]+)

Schlimmsten Fall (weniger performant, aber die Seite ist ja sehr kurz):
([-+ ]*[\d\.]+)<\/div


Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: MadMax-FHEM am 29 Dezember 2020, 11:34:14
Ganz kurze Anmerkung:

schon mal das Attribut 'showBody' gesetzt?
Dann sollte man doch sehen, was dem HTTPMOD "zur Verfügung steht"?

Gruß, Joachim
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: amenomade am 29 Dezember 2020, 11:55:42
Zitat von: MadMax-FHEM am 29 Dezember 2020, 11:34:14
Dann sollte man doch sehen, was dem HTTPMOD "zur Verfügung steht"?
Bis auf die Headers, und die "1.0" kommt höchstwahrscheinlich vom Header ;) Aber trotzdem ein guter Hinweis: damit könnte man vielleicht diese "div" Geschichte klären.
Allerdings sieht man mit verbose 5 schon die Headers und das body in der Log.
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: MadMax-FHEM am 29 Dezember 2020, 12:05:51
Drum ja auch: ganz kurze Anmerkung ;)

Viel Erfolg noch, Joachim
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: Thoffi1978 am 29 Dezember 2020, 15:55:03
Hallo,
ich habe alle Vorschläge einmal ausprobiert.
Leider ändert sich da noch nicht einmal der State (die Uhrzeit bleibt gleich)
Anbei Vorschlag und log:
<div>([-+ ]*[\d\.]+)
2020.12.29 15:41:41 4 : Temperatur: GetUpdate called (update)
2020.12.29 15:41:41 4 : Temperatur: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 120.0 sec at 2020-12-29 15:43:41, interval 120
2020.12.29 15:41:41 5 : Temperatur: AddToQueue adds type update to URL http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), no data, no headers, retry 0, initial queue len: 0
2020.12.29 15:41:41 5 : Temperatur: HandleSendQueue called from AddToSendQueue, qlen = 1
2020.12.29 15:41:41 4 : Temperatur: HandleSendQueue sends update with timeout 10 to http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), No Data, No Header
2020.12.29 15:41:42 5 : Temperatur: ReadCallback called from __ANON__
2020.12.29 15:41:42 4 : Temperatur: BodyDecode found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.12.29 15:41:42 4 : Temperatur: BodyDecode is decoding the response body as utf-8
2020.12.29 15:41:42 5 : Temperatur: GetCookies is looking for Cookies
2020.12.29 15:41:42 5 : Temperatur: ExtractSid called, context reading, num 0
2020.12.29 15:41:42 4 : Temperatur: checking for redirects, code=200, ignore=0
2020.12.29 15:41:42 4 : Temperatur: no redirects to handle
2020.12.29 15:41:42 5 : Temperatur: Read callback sets LAST_REQUEST to update
2020.12.29 15:41:42 5 : Temperatur: CheckAuth decided no authentication required
2020.12.29 15:41:42 5 : Temperatur: Read starts parsing response to update with defined readings: 01
2020.12.29 15:41:42 5 : Temperatur: ExtractReading state with regex /(?^:<div>([-+ ]*[\d\.]+))/...
2020.12.29 15:41:42 5 : Temperatur: ExtractReading state did not match
2020.12.29 15:41:42 4 : Temperatur: Read response to update didn't match any Reading
2020.12.29 15:41:42 5 : Temperatur: HandleSendQueue called from ReadCallback, qlen = 0
2020.12.29 15:41:42 5 : Temperatur: HandleSendQueue found no usable entry in queue
2020.12.29 15:41:42 4 : Temperatur: Read callback: request type was update retry 0, header: HTTP/1.0 200 OK Content-type: text/plain; charset=utf-8, body length 5
2020.12.29 15:41:42 5 : Temperatur: Read callback: body + 1.5</div>


(^[-+ ]*[\d\.]+)
2020.12.29 15:43:41 4 : Temperatur: GetUpdate called (update)
2020.12.29 15:43:41 4 : Temperatur: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 120.0 sec at 2020-12-29 15:45:41, interval 120
2020.12.29 15:43:41 5 : Temperatur: AddToQueue adds type update to URL http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), no data, no headers, retry 0, initial queue len: 0
2020.12.29 15:43:41 5 : Temperatur: HandleSendQueue called from AddToSendQueue, qlen = 1
2020.12.29 15:43:41 4 : Temperatur: HandleSendQueue sends update with timeout 10 to http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), No Data, No Header
2020.12.29 15:43:42 5 : Temperatur: ReadCallback called from __ANON__
2020.12.29 15:43:42 4 : Temperatur: BodyDecode found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.12.29 15:43:42 4 : Temperatur: BodyDecode is decoding the response body as utf-8
2020.12.29 15:43:42 5 : Temperatur: GetCookies is looking for Cookies
2020.12.29 15:43:42 5 : Temperatur: ExtractSid called, context reading, num 0
2020.12.29 15:43:42 4 : Temperatur: checking for redirects, code=200, ignore=0
2020.12.29 15:43:42 4 : Temperatur: no redirects to handle
2020.12.29 15:43:42 5 : Temperatur: Read callback sets LAST_REQUEST to update
2020.12.29 15:43:42 5 : Temperatur: CheckAuth decided no authentication required
2020.12.29 15:43:42 5 : Temperatur: UpdateReadingList created list of reading.* nums to parse during getUpdate as 01
2020.12.29 15:43:42 5 : Temperatur: Read starts parsing response to update with defined readings: 01
2020.12.29 15:43:42 5 : Temperatur: ExtractReading state with regex /(?^:([-+ ]*[\d\.]+)<\/div)/...
2020.12.29 15:43:42 5 : Temperatur: ExtractReading state did not match
2020.12.29 15:43:42 4 : Temperatur: Read response to update didn't match any Reading
2020.12.29 15:43:42 5 : Temperatur: HandleSendQueue called from ReadCallback, qlen = 0
2020.12.29 15:43:42 5 : Temperatur: HandleSendQueue found no usable entry in queue
2020.12.29 15:43:42 4 : Temperatur: Read callback: request type was update retry 0, header: HTTP/1.0 200 OK Content-type: text/plain; charset=utf-8, body length 5
2020.12.29 15:43:42 5 : Temperatur: Read callback: body + 1.5


([-+ ]*[\d\.]+)<\/div
2020.12.29 15:45:41 4 : Temperatur: GetUpdate called (update)
2020.12.29 15:45:41 4 : Temperatur: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 120.0 sec at 2020-12-29 15:47:41, interval 120
2020.12.29 15:45:41 5 : Temperatur: AddToQueue adds type update to URL http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), no data, no headers, retry 0, initial queue len: 0
2020.12.29 15:45:41 5 : Temperatur: HandleSendQueue called from AddToSendQueue, qlen = 1
2020.12.29 15:45:41 4 : Temperatur: HandleSendQueue sends update with timeout 10 to http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), No Data, No Header
2020.12.29 15:45:42 5 : Temperatur: ReadCallback called from __ANON__
2020.12.29 15:45:42 4 : Temperatur: BodyDecode found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.12.29 15:45:42 4 : Temperatur: BodyDecode is decoding the response body as utf-8
2020.12.29 15:45:42 5 : Temperatur: GetCookies is looking for Cookies
2020.12.29 15:45:42 5 : Temperatur: ExtractSid called, context reading, num 0
2020.12.29 15:45:42 4 : Temperatur: checking for redirects, code=200, ignore=0
2020.12.29 15:45:42 4 : Temperatur: no redirects to handle
2020.12.29 15:45:42 5 : Temperatur: Read callback sets LAST_REQUEST to update
2020.12.29 15:45:42 5 : Temperatur: CheckAuth decided no authentication required
2020.12.29 15:45:42 5 : Temperatur: UpdateReadingList created list of reading.* nums to parse during getUpdate as 01
2020.12.29 15:45:42 5 : Temperatur: Read starts parsing response to update with defined readings: 01
2020.12.29 15:45:42 5 : Temperatur: ExtractReading state with regex /(?^:(^[-+ ]*[\d\.]+))/...
2020.12.29 15:45:42 5 : Temperatur: ExtractReading state did not match
2020.12.29 15:45:42 4 : Temperatur: Read response to update didn't match any Reading
2020.12.29 15:45:42 5 : Temperatur: HandleSendQueue called from ReadCallback, qlen = 0
2020.12.29 15:45:42 5 : Temperatur: HandleSendQueue found no usable entry in queue
2020.12.29 15:45:42 4 : Temperatur: Read callback: request type was update retry 0, header: HTTP/1.0 200 OK Content-type: text/plain; charset=utf-8, body length 5
2020.12.29 15:45:42 5 : Temperatur: Read callback: body + 1.5


und einmal
([-+ ]*[\d\.]+)<\/div mit ShowBody
2020.12.29 15:51:41 4 : Temperatur: GetUpdate called (update)
2020.12.29 15:51:41 4 : Temperatur: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 120.0 sec at 2020-12-29 15:53:41, interval 120
2020.12.29 15:51:41 5 : Temperatur: AddToQueue adds type update to URL http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), no data, no headers, retry 0, initial queue len: 0
2020.12.29 15:51:41 5 : Temperatur: HandleSendQueue called from AddToSendQueue, qlen = 1
2020.12.29 15:51:41 4 : Temperatur: HandleSendQueue sends update with timeout 10 to http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), No Data, No Header
2020.12.29 15:51:42 5 : Temperatur: ReadCallback called from __ANON__
2020.12.29 15:51:42 4 : Temperatur: BodyDecode found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.12.29 15:51:42 4 : Temperatur: BodyDecode is decoding the response body as utf-8
2020.12.29 15:51:42 5 : Temperatur: GetCookies is looking for Cookies
2020.12.29 15:51:42 5 : Temperatur: ExtractSid called, context reading, num 0
2020.12.29 15:51:42 4 : Temperatur: checking for redirects, code=200, ignore=0
2020.12.29 15:51:42 4 : Temperatur: no redirects to handle
2020.12.29 15:51:42 5 : Temperatur: Read callback sets LAST_REQUEST to update
2020.12.29 15:51:42 5 : Temperatur: CheckAuth decided no authentication required
2020.12.29 15:51:42 5 : Temperatur: Read starts parsing response to update with defined readings: 01
2020.12.29 15:51:42 5 : Temperatur: ExtractReading state with regex /(?^:(^[-+ ]*[\d\.]+))/...
2020.12.29 15:51:42 5 : Temperatur: ExtractReading state did not match
2020.12.29 15:51:42 4 : Temperatur: Read response to update didn't match any Reading
2020.12.29 15:51:42 5 : Temperatur: HandleSendQueue called from ReadCallback, qlen = 0
2020.12.29 15:51:42 5 : Temperatur: HandleSendQueue found no usable entry in queue
2020.12.29 15:51:42 4 : Temperatur: Read callback: request type was update retry 0, header: HTTP/1.0 200 OK Content-type: text/plain; charset=utf-8, body length 5
2020.12.29 15:51:42 5 : Temperatur: Read callback: body + 1.5


list Temperatur:
Internals:
   .LASTSEND  1609253501.47049
   .LastUpdate 1609253501.46044
   .TRIGGERTIME 1609253621.46044
   .getList   
   .setList   interval reread:noArg stop:noArg start:noArg clearCookies:noArg upgradeAttributes:noArg storeKeyValue
   .updateRequestHash 1
   BUSY       0
   DEF        http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS) 120
   FUUID      5f6b88ec-f33f-7e98-8cad-ca7470639ca5faf7
   Interval   120
   MainURL    http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS)
   ModuleVersion 4.0.16 - 5.12.2020
   NAME       Temperatur
   NOTIFYDEV  global
   NR         451
   NTFY_ORDER 50-Temperatur
   STATE      1.0
   TYPE       HTTPMOD
   httpbody   + 1.5
   value     
   .attraggr:
   .attrminint:
   .readingParseList:
     01
   CompiledRegexes:
   HttpUtils:
     NAME       
     addr       http://192.168.2.12:80
     auth       1
     code       200
     compress   1
     conn       
     data       
     displayurl http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS)
     header     
     host       192.168.2.12
     httpheader HTTP/1.0 200 OK
Content-type: text/plain; charset=utf-8
     httpversion 1.0
     hu_blocking 0
     hu_filecount 1
     hu_port    80
     hu_portSfx
     ignoreredirects 1
     loglevel   4
     path       /control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS)
     protocol   http
     pwd        fhem1234
     redirects  0
     timeout    10
     url        http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS)
     user       Fhem
     sslargs:
   QUEUE:
   READINGS:
     2020-12-29 15:29:42   state           1.0
   REQUEST:
     context    reading
     data       
     header     
     ignoreredirects 0
     num        0
     retryCount 0
     type       update
     url        http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS)
   defptr:
     readingBase:
       state      reading
     readingNum:
       state      01
     readingOutdated:
     requestReadings:
       update:
         state      reading 01
Attributes:
   reading01Name state
   reading01Regex (^[-+ ]*[\d\.]+)
   room       Haus
   showBody   1
   timeout    10
   verbose    5


Die Temperatur (+ 1.5) wird überall mit ausgegeben, doch sie wird nicht als "Reading" übernommen.


Hoffi
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: amenomade am 29 Dezember 2020, 18:52:57
Kannst Du bitte mit F12 Tools im Netzwerk Reiter zeigen, was er genau macht bei einer Abfrage der Seite im Browser?
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: Thoffi1978 am 30 Dezember 2020, 08:42:05
Guten Morgen,

anbei 3 Fotos. Ich hoffe das man daraus etwss erkennen kann.

Vielen lieben Dank für die Mühen.

Hoffi
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: amenomade am 30 Dezember 2020, 11:01:40
Kannst Du noch bitte aus dem 2. Bild (network edge) auf dem Reiter Response klicken und das Bild vom 2. Abschnitt ("raw" Antwort) schicken?
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: Thoffi1978 am 30 Dezember 2020, 15:39:49
Anbei der Screenshot. Ich hoffe, dass dies der richtige ist.

Hoffi
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: amenomade am 30 Dezember 2020, 17:36:47
Na gut, die "Response" ist aber doch simpel... Ich weiss immer noch nicht wo dieses /div herkommt.

Versuche dann mit
(?s)\/head.*?([-+ ]*[\d\.]+)
oder
(?s)body.*?([-+ ]*[\d\.]+)
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: xenos1984 am 30 Dezember 2020, 17:50:10
Ich würde vielleicht noch mal schauen, ob das, was da wie ein Leerzeichen aussieht, wirklich eins ist, und nicht irgendein gleich aussehendes Zeichen wie z.B. ein "non-breaking space" oder ähnliches. In dem Fall würde die RegEx nicht passen und man bräuchte eher sowas:

^[-+\s]*[\d\.]+
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: amenomade am 30 Dezember 2020, 18:00:32
Zitat von: xenos1984 am 30 Dezember 2020, 17:50:10
Ich würde vielleicht noch mal schauen, ob das, was da wie ein Leerzeichen aussieht, wirklich eins ist, und nicht irgendein gleich aussehendes Zeichen wie z.B. ein "non-breaking space" oder ähnliches. In dem Fall würde die RegEx nicht passen und man bräuchte eher sowas:

^[-+\s]*[\d\.]+
Hast recht
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: Thoffi1978 am 31 Dezember 2020, 08:42:43
Hallo,
ich habe alle 3 Vorschläge ausprobiert. Die Temperatur wird wohl schon ausgelesen. Der httpbody ist passend gefüllt.
Leider wird der Wert aber nicht in den State übergeben.

Hier die vorgeschlagenen Regex und der passende Log:
^[-+\s]*[\d\.]+
2020.12.31 08:21:47 4 : Temperatur: GetUpdate called (update)
2020.12.31 08:21:47 4 : Temperatur: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 120.0 sec at 2020-12-31 08:23:47, interval 120
2020.12.31 08:21:47 5 : Temperatur: AddToQueue adds type update to URL http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), no data, no headers, retry 0, initial queue len: 0
2020.12.31 08:21:47 5 : Temperatur: HandleSendQueue called from AddToSendQueue, qlen = 1
2020.12.31 08:21:47 4 : Temperatur: HandleSendQueue sends update with timeout 10 to http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), No Data, No Header
2020.12.31 08:21:47 5 : Temperatur: ReadCallback called from __ANON__
2020.12.31 08:21:47 4 : Temperatur: BodyDecode found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.12.31 08:21:47 4 : Temperatur: BodyDecode is decoding the response body as utf-8
2020.12.31 08:21:47 5 : Temperatur: GetCookies is looking for Cookies
2020.12.31 08:21:47 5 : Temperatur: ExtractSid called, context reading, num 0
2020.12.31 08:21:47 4 : Temperatur: checking for redirects, code=200, ignore=0
2020.12.31 08:21:47 4 : Temperatur: no redirects to handle
2020.12.31 08:21:47 5 : Temperatur: Read callback sets LAST_REQUEST to update
2020.12.31 08:21:47 5 : Temperatur: CheckAuth decided no authentication required
2020.12.31 08:21:47 5 : Temperatur: Read starts parsing response to update with defined readings: 01
2020.12.31 08:21:47 5 : Temperatur: ExtractReading state with regex /(?^:^[-+\s]*[\d\.]+)/...
2020.12.31 08:21:47 5 : Temperatur: ExtractReading state did not match
2020.12.31 08:21:47 4 : Temperatur: Read response to update didn't match any Reading
2020.12.31 08:21:47 5 : Temperatur: HandleSendQueue called from ReadCallback, qlen = 0
2020.12.31 08:21:47 5 : Temperatur: HandleSendQueue found no usable entry in queue
2020.12.31 08:21:47 4 : Temperatur: Read callback: request type was update retry 0, header: HTTP/1.0 200 OK Content-type: text/plain; charset=utf-8, body length 5
2020.12.31 08:21:47 5 : Temperatur: Read callback: body + 3.1


^[-+\s]*[\d\.]+
2020.12.31 08:25:47 4 : Temperatur: GetUpdate called (update)
2020.12.31 08:25:47 4 : Temperatur: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 120.0 sec at 2020-12-31 08:27:47, interval 120
2020.12.31 08:25:47 5 : Temperatur: AddToQueue adds type update to URL http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), no data, no headers, retry 0, initial queue len: 0
2020.12.31 08:25:47 5 : Temperatur: HandleSendQueue called from AddToSendQueue, qlen = 1
2020.12.31 08:25:47 4 : Temperatur: HandleSendQueue sends update with timeout 10 to http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), No Data, No Header
2020.12.31 08:25:47 5 : Temperatur: ReadCallback called from __ANON__
2020.12.31 08:25:47 4 : Temperatur: BodyDecode found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.12.31 08:25:47 4 : Temperatur: BodyDecode is decoding the response body as utf-8
2020.12.31 08:25:47 5 : Temperatur: GetCookies is looking for Cookies
2020.12.31 08:25:47 5 : Temperatur: ExtractSid called, context reading, num 0
2020.12.31 08:25:47 4 : Temperatur: checking for redirects, code=200, ignore=0
2020.12.31 08:25:47 4 : Temperatur: no redirects to handle
2020.12.31 08:25:47 5 : Temperatur: Read callback sets LAST_REQUEST to update
2020.12.31 08:25:47 5 : Temperatur: CheckAuth decided no authentication required
2020.12.31 08:25:48 5 : Temperatur: Read starts parsing response to update with defined readings: 01
2020.12.31 08:25:48 5 : Temperatur: ExtractReading state with regex /(?^:(?s)body.*?([-+ ]*[\d\.]+))/...
2020.12.31 08:25:48 5 : Temperatur: ExtractReading state did not match
2020.12.31 08:25:48 4 : Temperatur: Read response to update didn't match any Reading
2020.12.31 08:25:48 5 : Temperatur: HandleSendQueue called from ReadCallback, qlen = 0
2020.12.31 08:25:48 5 : Temperatur: HandleSendQueue found no usable entry in queue
2020.12.31 08:25:47 4 : Temperatur: Read callback: request type was update retry 0, header: HTTP/1.0 200 OK Content-type: text/plain; charset=utf-8, body length 5
2020.12.31 08:25:47 5 : Temperatur: Read callback: body + 3.1


(?s)\/head.*?([-+ ]*[\d\.]+)
2020.12.31 08:27:47 4 : Temperatur: GetUpdate called (update)
2020.12.31 08:27:47 4 : Temperatur: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 120.0 sec at 2020-12-31 08:29:47, interval 120
2020.12.31 08:27:47 5 : Temperatur: AddToQueue adds type update to URL http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), no data, no headers, retry 0, initial queue len: 0
2020.12.31 08:27:47 5 : Temperatur: HandleSendQueue called from AddToSendQueue, qlen = 1
2020.12.31 08:27:47 4 : Temperatur: HandleSendQueue sends update with timeout 10 to http://Fhem:fhem1234@192.168.2.12/control/rcontrol?action=gettext&message=$(SEN.TIN.CELSIUS), No Data, No Header
2020.12.31 08:27:48 5 : Temperatur: ReadCallback called from __ANON__
2020.12.31 08:27:48 4 : Temperatur: BodyDecode found charset header and set decoding to utf-8 (bodyDecode was set to auto)
2020.12.31 08:27:48 4 : Temperatur: BodyDecode is decoding the response body as utf-8
2020.12.31 08:27:48 5 : Temperatur: GetCookies is looking for Cookies
2020.12.31 08:27:48 5 : Temperatur: ExtractSid called, context reading, num 0
2020.12.31 08:27:48 4 : Temperatur: checking for redirects, code=200, ignore=0
2020.12.31 08:27:48 4 : Temperatur: no redirects to handle
2020.12.31 08:27:48 5 : Temperatur: Read callback sets LAST_REQUEST to update
2020.12.31 08:27:48 5 : Temperatur: CheckAuth decided no authentication required
2020.12.31 08:27:48 5 : Temperatur: UpdateReadingList created list of reading.* nums to parse during getUpdate as 01
2020.12.31 08:27:48 5 : Temperatur: Read starts parsing response to update with defined readings: 01
2020.12.31 08:27:48 5 : Temperatur: ExtractReading state with regex /(?^:(?s)\/head.*?([-+ ]*[\d\.]+))/...
2020.12.31 08:27:48 5 : Temperatur: ExtractReading state did not match
2020.12.31 08:27:48 4 : Temperatur: Read response to update didn't match any Reading
2020.12.31 08:27:48 5 : Temperatur: HandleSendQueue called from ReadCallback, qlen = 0
2020.12.31 08:27:48 5 : Temperatur: HandleSendQueue found no usable entry in queue
2020.12.31 08:27:48 4 : Temperatur: Read callback: request type was update retry 0, header: HTTP/1.0 200 OK Content-type: text/plain; charset=utf-8, body length 5
2020.12.31 08:27:48 5 : Temperatur: Read callback: body + 3.1


Hoffi
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: amenomade am 31 Dezember 2020, 13:57:57
OK, hab's mit mocky.io getestet. Mit
\n([-+ ]*[\d\.]+)
scheint es zu gehen
Titel: Antw:Regex wird nicht immer ausgelesen
Beitrag von: Thoffi1978 am 01 Januar 2021, 17:22:51
Das war´s.

Die Temperatur wird wieder angezeigt.
Der FileLog wird auch beschrieben.


Ein Superherzlichen Dank

Hoffi