Servus,
ich wollte gestern mit httpmod den Status der Motioneye Detection auslesen. httpmod findet scheinbar den String den ich suche, gibt aber allerdings nicht den String zurück sondern immer nur 1. Laut regex101 stimmt der Regex auch. Es soll also in dem Beispiel "NOT RUNNING" angezeigt werden. Es ist bestimmt ein einfacher Fehler/ Eintellung nur wo?
Listing httpmod Modul:
Internals:
BUSY 0
DEF http://172.18.0.30:7999/0/detection/status 300
FUUID 638b6320-f33f-39ed-a04c-fd9bd35a1e70521e
Interval 300
MainURL http://172.18.0.30:7999/0/detection/status
ModuleVersion 4.1.14 - 19.8.2022
NAME Motion_detect
NOTIFYDEV global
NR 271
NTFY_ORDER 50-Motion_detect
STATE ???
TYPE HTTPMOD
eventCount 105
httpbody <!DOCTYPE html>
<html>
<head><title>Motion 4.1.1</title></head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<body>
<a href=/0/detection><– back</a><br><br><b>Camera 0</b> Detection status NOT RUNNING
</body>
</html>
value
CompiledRegexes:
HttpUtils:
NAME
addr http://172.18.0.30:7999
auth 0
code 200
compress 1
conn
data
displayurl http://172.18.0.30:7999/0/detection/status
header
host 172.18.0.30
httpheader HTTP/1.1 200 OK
Server: Motion-httpd/4.1.1
Connection: close
Max-Age: 0
Expires: 0
Cache-Control: no-cache
Cache-Control: private
Pragma: no-cache
Content-type: text/html
httpversion 1.0
hu_blocking 0
hu_filecount 1
hu_port 7999
hu_portSfx :7999
ignoreredirects 1
loglevel 4
path /0/detection/status
protocol http
redirects 0
timeout 2
url http://172.18.0.30:7999/0/detection/status
sslargs:
QUEUE:
READINGS:
2022-12-05 09:53:58 LAST_REQUEST update
2022-12-05 09:53:58 MATCHED_READINGS Status
2022-12-05 09:53:58 Status 1
2022-12-05 09:53:58 UNMATCHED_READINGS
REQUEST:
context reading
data
header
ignoreredirects 0
num unknown
retryCount 0
type update
url http://172.18.0.30:7999/0/detection/status
defptr:
readingBase:
Status reading
readingNum:
Status 01
readingOutdated:
requestReadings:
update:
Status reading 01
Attributes:
bodyDecode UTF-8
reading01Name Status
reading01Regex Detection status(?:.*)
room Alarmanlage
set01Name An
set01URL http://172.18.0.30:7999/0/detection/start
set02Name Aus
set02URL http://172.18.0.30:7999/0/detection/pause
showBody 1
showMatched 1
verbose 5
Quellcode der azufragen Seite:
<!DOCTYPE html>
<html>
<head><title>Motion 4.1.1</title></head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<body>
<a href=/0/detection><– back</a><br><br><b>Camera 0</b> Detection status NOT RUNNING
</body>
</html>
Log von Fhem:
2022.12.05 09:58:36 5: Motion_detect: set called with reread
2022.12.05 09:58:36 4: Motion_detect: GetUpdate called (reread)
2022.12.05 09:58:36 5: Motion_detect: AddToQueue adds type update to URL http://172.18.0.30:7999/0/detection/status, no data, no headers, retry 0, initial queue len: 0
2022.12.05 09:58:36 5: Motion_detect: HandleSendQueue called from AddToSendQueue, qlen = 1
2022.12.05 09:58:36 4: Motion_detect: HandleSendQueue sends update with timeout 2 to http://172.18.0.30:7999/0/detection/status, No Data, No Header
2022.12.05 09:58:36 5: Motion_detect: ReadCallback called from __ANON__
2022.12.05 09:58:36 4: Motion_detect: Read callback: request type was update retry 0,
header: HTTP/1.1 200 OK
Server: Motion-httpd/4.1.1
Connection: close
Max-Age: 0
Expires: 0
Cache-Control: no-cache
Cache-Control: private
Pragma: no-cache
Content-type: text/html, body length 271
2022.12.05 09:58:36 5: Motion_detect: Read callback: body
<!DOCTYPE html>
<html>
<head><title>Motion 4.1.1</title></head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<body>
<a href=/0/detection><– back</a><br><br><b>Camera 0</b> Detection status NOT RUNNING
</body>
</html>
2022.12.05 09:58:36 4: Motion_detect: BodyDecode is decoding the response body as UTF-8 but charset header is not found
2022.12.05 09:58:36 5: Motion_detect: GetCookies is looking for Cookies
2022.12.05 09:58:36 5: Motion_detect: ExtractSid called, context reading, num unknown
2022.12.05 09:58:36 4: Motion_detect: checking for redirects, code=200, ignore=0
2022.12.05 09:58:36 4: Motion_detect: no redirects to handle
2022.12.05 09:58:36 5: Motion_detect: Read callback sets LAST_REQUEST to update
2022.12.05 09:58:36 5: Motion_detect: CheckAuth decided no authentication required
2022.12.05 09:58:36 5: Motion_detect: Read starts parsing response to update with defined readings: 01
2022.12.05 09:58:36 5: Motion_detect: ExtractReading Status with regex /(?^:Detection status(?:.*))/...
2022.12.05 09:58:36 5: Motion_detect: FormatReading is encoding the reading value as utf-8 because no encoding was specified and the response body charset was unknown or decoded
2022.12.05 09:58:36 5: Motion_detect: ExtractReading for reading01-1 sets Status to 1
2022.12.05 09:58:36 5: Motion_detect: ExtractReading value as hex is 31
2022.12.05 09:58:36 4: Motion_detect: Read response matched 1, unmatch 0 Reading(s)
2022.12.05 09:58:36 5: Motion_detect: Read response to update matched Status
2022.12.05 09:58:36 5: Motion_detect: HandleSendQueue called from ReadCallback, qlen = 0
2022.12.05 09:58:36 5: Motion_detect: HandleSendQueue found no usable entry in queue
2022.12.05 09:58:36 5: Motion_detect: ExtractReading Status with regex /(?^:Detection status(?:.*))/...
Mach mal in Deinem RegEx am Anfang ein .* rein ...
Kleine Anmerkung noch:
Du hast viel in Code-Tags gepackt und das ist super! Aber ... könntest Du das bitte auch in Logausgaben so machen? Vereinfacht das lesen ungemein ...
Probiert, hilft leider auch nichts, kommt immer noch 1...
Log ist auch als Code drin ;)
Hinweis: Bin nicht der httpmod Experte, habe da auch so meine Probleme ..
Kannst Du mal Deine Seite incl. Header, also Komplett, posten?
Hatte bei mir bei meinen letzten Problemen einen Match im Header, denn ich einfach nicht gesehen habe, da ich nur auf dem Body geguckt habe.
Und noch eine "Kleinigkeit":
ZitatModule: 98_HTTPMOD.pm Maintainer: StefanStrobel Forum: Sonstiges
Kannst Du es bitte zu "Sonstiges" verschieben? Damit es die Richtigen "finden"? Einfach für Qualifiziertere Meldungen ..
Obige Ausgabe kann man i9n fhem mit "help httpmod" bekommen.
Das oben ist die komplette Seite, die ist quasi nur dazu da um über http befehle das System zu steuern / abzufragen...
Danke und ist verschoben
was ergibt folgendes?
reading01Regex Detection status(.*)
Als du das geschrieben hast habe ich es auch so probiert, jetzt funktioniert es.... Ich sage doch es war was einfaches....
Jetzt sieht so aus und funktioniert:
defmod Motion_detect HTTPMOD http://172.18.0.30:7999/0/detection/status 300
attr Motion_detect reading01Name Status
attr Motion_detect reading01Regex Detection status(.*)
attr Motion_detect room Alarmanlage
attr Motion_detect set01Name An
attr Motion_detect set01URL http://172.18.0.30:7999/0/detection/start
attr Motion_detect set02Name Aus
attr Motion_detect set02URL http://172.18.0.30:7999/0/detection/pause
setstate Motion_detect 2022-12-05 11:15:35 Status NOT RUNNING
Besten Dank!!!
das leerzeichen nach status würde ich noch aus dem reading entfernen:
attr Motion_detect reading01Regex Detection status (.*)
Gut das es Funktioniert,
aber mit "Header" meinte ich mehr, als Du geschrieben hast. Allerdings habe ich übersehen, das es auch in Deinen Logs zu finden war. Als Auszug:
header: HTTP/1.1 200 OK
Server: Motion-httpd/4.1.1
Connection: close
Max-Age: 0
.......