Hilfe zu HTTPMOD, verstehe leider nur Bahnhof...

Begonnen von Ma_Bo, 28 März 2017, 15:53:59

Vorheriges Thema - Nächstes Thema

amenomade

@Ma_Bo: probier sowas:
define Traccar HTTPMOD http://192.168.0.45:8082/traccar/rest/getLatestPositions 60
attr Traccar enableCookies 1
attr Traccar verbose 5
attr Traccar extractAllJSON 1
attr Traccar reAuthRegex /rest/login
attr Traccar sid1URL http://192.168.0.45:8082/traccar/rest/login?payload=[fhem,fhem]


Erklärung (wenn StefanStrobel in der Nähe, bitte um Korrektur/Ergänzung):
- define auf die Poll URL wo deine interessante Werte sind
- attr enableCookies selbst erklärend
- attr extractAllJSON zumindest am Anfang, bist du weiter in Details von den Readings forschst- erstmal alles holen und extrahieren
- attr reAuthRegex : detektieren, wenn ein Login nötig ist, durch irgendwelche regex. Da gehe ich davon aus, dass dein Ding einfach die Login Seite zurückschickt, wenn man sich anmelden muss
- attr sid1URL: ruf die AuthentifizierungsURL mit payload user,password: normalerweise laut Traccar Doku, sollte es reichen, um sich anzumelden, und sid oder jsessionid zu bekommen

Weitere Polling Verfahren mit
attr Traccar get[0-9]URL im gleichen Device (define).

Probier mal, und poste mal die list und logs.



@rohlande: was ergibt bei dir http://192.168.178.20:55000/traccar/rest/login?payload=[fhem,fhem] in einem Browser?

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

rohlande

#16
@amenomade:

die URL gibt mir im BROWSER ein "404 not Found" wieder.

list httmoddevice:
Internals:
   BUSY       0
   CHANGED
   DEF        http://192.168.178.20:55001/traccar/rest/login?payload=[fhem,fhem] 60
   HTTPCookies
   Interval   60
   JSONEnabled 1
   LASTSEND   1493919188.12202
   MainURL    http://192.168.178.20:55001/traccar/rest/login?payload=[fhem,fhem]
   ModuleVersion 3.3.9 - 23.3.2017
   NAME       Traccar_HTTPMOD_Login
   NR         399
   STATE      ???
   TRIGGERTIME 1493919248.12126
   TRIGGERTIME_FMT 2017-05-04 19:34:08
   TYPE       HTTPMOD
   addr       http://192.168.178.20:55001
   buf
   data
   displayurl http://192.168.178.20:55001/traccar/rest/login?payload=[fhem,fhem]
   header
   host       192.168.178.20
   httpversion 1.0
   ignoreredirects 0
   loglevel   4
   path       /traccar/rest/login?payload=[fhem,fhem]
   protocol   http
   redirects  0
   timeout    2
   url        http://192.168.178.20:55001/traccar/rest/login?payload=[fhem,fhem]
   value      0
   Httpcookiehash:
   QUEUE:
   Readings:
   Request:
     data
     header
     ignoreredirects 0
     retryCount 0
     type       update
     url        http://192.168.178.20:55001/traccar/rest/login?payload=[fhem,fhem]
     value      0
   Sslargs:
Attributes:
   enableCookies 1
   extractAllJSON 1
   room       Halle
   verbose    2


Ok. der 404 ist scheinbar weg. Komisch  :o
Nun muss ich wohl die Session hinbekommen.


EDIT: Ups Fehler drin im Port. 404 kommt weiterhin. ich hatte nur einen weiteren Port geteset.

hier der aktuelle Auszug, welcher auch im Browser nicht funnktioniert


Internals:
   BUSY       0
   CHANGED
   DEF        http://192.168.178.20:55000/traccar/rest/login?payload=[fhem,fhem] 60
   HTTPCookies
   Interval   60
   JSONEnabled 1
   LASTSEND   1493920431.74037
   MainURL    http://192.168.178.20:55000/traccar/rest/login?payload=[fhem,fhem]
   ModuleVersion 3.3.9 - 23.3.2017
   NAME       Traccar_HTTPMOD_Login
   NR         399
   STATE      ???
   TRIGGERTIME 1493920491.73923
   TRIGGERTIME_FMT 2017-05-04 19:54:51
   TYPE       HTTPMOD
   addr       http://192.168.178.20:55000
   buf
   code       404
   conn
   data
   displayurl http://192.168.178.20:55000/traccar/rest/login?payload=[fhem,fhem]
   header
   host       192.168.178.20
   httpheader HTTP/1.1 404 Not Found

Date: Thu, 04 May 2017 17:53:51 GMT

Content-Type: text/html; charset=ISO-8859-1

Cache-Control: must-revalidate,no-cache,no-store

Content-Length: 89

Server: Jetty(9.2.19.v20160908)
   httpversion 1.0
   hu_blocking 0
   hu_filecount 5
   hu_portSfx :55000
   ignoreredirects 0
   loglevel   4
   path       /traccar/rest/login?payload=[fhem,fhem]
   protocol   http
   redirects  0
   timeout    2
   url        http://192.168.178.20:55000/traccar/rest/login?payload=[fhem,fhem]
   value      0
   Httpcookiehash:
   QUEUE:
   Readings:
   Request:
     data
     header
     ignoreredirects 0
     retryCount 0
     type       update
     url        http://192.168.178.20:55000/traccar/rest/login?payload=[fhem,fhem]
     value      0
   Sslargs:
Attributes:
   enableCookies 1
   extractAllJSON 1
   reAuthRegex /traccar/rest/
   room       Halle
   verbose    5

HostSystem: Synology DS918 | FHEM im Docker Version: 6.0-s22528_v2.2.4 (dedizierte IP Adresse) | MQTT_Broker auf DS918 NAS | MQTT_FHEM | TASMOTA_DEVICE | SSChatBot | SSCam | LaMetric | FBAHAHTTP | CUL | SONOS | HUEBridge (deCONZ) Zigbee | FB_CALLMONITOR | InfluxDBLogger

Ma_Bo

Zitat von: amenomade am 04 Mai 2017, 16:10:59
@Ma_Bo: probier sowas:
define Traccar HTTPMOD http://192.168.0.45:8082/traccar/rest/getLatestPositions 60
attr Traccar enableCookies 1
attr Traccar verbose 5
attr Traccar extractAllJSON 1
attr Traccar reAuthRegex /rest/login
attr Traccar sid1URL http://192.168.0.45:8082/traccar/rest/login?payload=[fhem,fhem]


Erklärung (wenn StefanStrobel in der Nähe, bitte um Korrektur/Ergänzung):
- define auf die Poll URL wo deine interessante Werte sind
- attr enableCookies selbst erklärend
- attr extractAllJSON zumindest am Anfang, bist du weiter in Details von den Readings forschst- erstmal alles holen und extrahieren
- attr reAuthRegex : detektieren, wenn ein Login nötig ist, durch irgendwelche regex. Da gehe ich davon aus, dass dein Ding einfach die Login Seite zurückschickt, wenn man sich anmelden muss
- attr sid1URL: ruf die AuthentifizierungsURL mit payload user,password: normalerweise laut Traccar Doku, sollte es reichen, um sich anzumelden, und sid oder jsessionid zu bekommen

Weitere Polling Verfahren mit
attr Traccar get[0-9]URL im gleichen Device (define).

Probier mal, und poste mal die list und logs.



@rohlande: was ergibt bei dir http://192.168.178.20:55000/traccar/rest/login?payload=[fhem,fhem] in einem Browser?

Gruß

Danke für das Beispiel, werde ich sobald wie möglich testen, leider wird das erst nächste Woche werden. Ggfs. schaffe ich das diese oder morgen Nacht noch.
Ich werde dann berichten.
NUC mit FHEM, HM Heizungsthermostate, HM Wandthermostate, Intertechno Funksteckdosen, 10" Tablet als Wanddisplay, KeyMatic, Fensterkontakte, Fensterkontakte umgebaut als Wassermelder und Briefkastenmelder, Aussenthermostat, Anwesenheitssteuerung über Fritz Box, Google Home usw. usw.

amenomade

@rohlande:
Zitatdie URL gibt mir im BROWSER ein "404 not Found"
Dann musst du das erstmal lösen, das hat nichts mit FHEM zu tun. Ich würde sagen, dir fehlt noch etwas wie die so genannte "RestFul API" http://traccar.litvak.su/features/rest-api.html. Ohne diese API ist bestimmt eine andere Vorgehensweise zu suchen: andere URLs, usw.
So lang du keine vernünftige Vorgehensweise in einem Browser hast, brauchst Du nicht, es versuchen, in fhem zu implementieren!


@Ma_bo: kein Thema, ich bin nicht in Eile. Du bist derjenige, der an die Sache interessiert ist  ;)

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

rohlande

#19
ja das dachte ich mir schon.
Meine Traccar Instanz läuft auf einer Synology. Diese scheint eine Andere zu sein welche hier verwendet wird.
Obwohl diese von der Traccar Seite kommt.

Gruss Denny

Edit:

also auch die aktuelle Version löst das Problem nicht.
traccar3.10-016-noarch.spk
Schade! :-(

Ich habe den Entwickler angeschrieben mal sehen was kommt.
Schönen Abend noch Zusammen,
HostSystem: Synology DS918 | FHEM im Docker Version: 6.0-s22528_v2.2.4 (dedizierte IP Adresse) | MQTT_Broker auf DS918 NAS | MQTT_FHEM | TASMOTA_DEVICE | SSChatBot | SSCam | LaMetric | FBAHAHTTP | CUL | SONOS | HUEBridge (deCONZ) Zigbee | FB_CALLMONITOR | InfluxDBLogger

Ma_Bo

Ich glaube du versuchst den falschen Port zu erreichen, das wird der Port sein, an den die Geräte senden.
NUC mit FHEM, HM Heizungsthermostate, HM Wandthermostate, Intertechno Funksteckdosen, 10" Tablet als Wanddisplay, KeyMatic, Fensterkontakte, Fensterkontakte umgebaut als Wassermelder und Briefkastenmelder, Aussenthermostat, Anwesenheitssteuerung über Fritz Box, Google Home usw. usw.

amenomade

#21
@Ma_Bo: Ne, auf Synology ist der Port 55000 laut Doku zu nutzen. Ich glaube, das Problem ist eher, dass er versucht, die RESTful API von litvak zu nutzen, ohnedie  installiert zu haben. Die RESTful API ist laut Litvak "a modified version of traccar-web".

@rohlande:
Was ergeben folgende Aufrufe in einem Browser?http://192.168.178.20:55000
http://192.168.178.20:55000/api/devices
http://192.168.178.20:55000/api/devices?payload=[fhem,fhem]
in einem Browser?

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

rohlande

#22
@amenomade:

Also 1. habe ich den Entwickler angeschrieben welcher mich an Entwickler  für die Synology verwiesen hat.
Es scheint wohl so zu sein, das laut "1sthandy", welcher der Entwickler  für die Synology ist, nur die Installationsroutine für die Synology angepasst wurde.
Der Rest scheint Java zu sein.

2. habe ich mit Deinen Tipps der URL herum gespielt und konnte schonmal auf die Header und einige weitere Infos aus der MYSQL zugreifen.

[{"id":1,"attributes":{},"name":"Denny","uniqueId":"627038","status":"online","lastUpdate":"2017-05-07T12:30:33.422+0000","positionId":1355,"groupId":0,"geofenceIds":[],"phone":"xxxxxxxxxxx","model":"BlackBerry","contact":"Denny","category":"car"},{"id":2,"attributes":{},"name":"Sabine","uniqueId":"264804","status":"online","lastUpdate":"2017-05-07T12:28:08.854+0000","positionId":1353,"groupId":0,"geofenceIds":[],"phone":"xxxxxxxxxxxx","model":"HTC one Mini II","contact":"Sabine","category":"person"},{"id":3,"attributes":{},"name":"Mama","uniqueId":"519929","status":"online","lastUpdate":"2017-05-07T12:29:26.476+0000","positionId":1354,"groupId":0,"geofenceIds":[],"phone":"xxxxxxxxxxxx","model":"Samsung J5","contact":"Beate","category":"person"}]

das list httpmodlistdevice:

Internals:
   BUSY       0
   CHANGED
   DEF        http://192.168.178.20:55000/api/devices?payload=[fhem,fhem] 60
   HTTPCookies
   Interval   60
   JSONEnabled 1
   LASTSEND   1494160844.04444
   MainURL    http://192.168.178.20:55000/api/devices?payload=[fhem,fhem]
   ModuleVersion 3.3.9 - 23.3.2017
   NAME       Traccar_HTTPMOD_Login
   NR         399
   STATE      ???
   TRIGGERTIME 1494160904.04326
   TRIGGERTIME_FMT 2017-05-07 14:41:44
   TYPE       HTTPMOD
   addr       http://192.168.178.20:55000
   buf
   code       415
   conn
   data
   displayurl http://192.168.178.20:55000/api/devices?payload=[fhem,fhem]
   header
   host       192.168.178.20
   httpheader HTTP/1.1 415 Unsupported Media Type

Date: Sun, 07 May 2017 12:40:44 GMT

Access-Control-Allow-Headers: origin, content-type, accept, authorization

Access-Control-Allow-Credentials: true

Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS

Access-Control-Allow-Origin: *

Content-Length: 61

Server: Jetty(9.2.21.v20170120)
   httpversion 1.0
   hu_blocking 0
   hu_filecount 1195
   hu_portSfx :55000
   ignoreredirects 0
   loglevel   4
   path       /api/devices?payload=[fhem,fhem]
   protocol   http
   redirects  0
   timeout    2
   url        http://192.168.178.20:55000/api/devices?payload=[fhem,fhem]
   value      0
   Httpcookiehash:
   QUEUE:
   Readings:
   Request:
     data
     header
     ignoreredirects 0
     retryCount 0
     type       update
     url        http://192.168.178.20:55000/api/devices?payload=[fhem,fhem]
     value      0
   Sslargs:
Attributes:
   enableCookies 1
   extractAllJSON 1
   room       Halle
   verbose    5



So hier noch der log:
2017.05.07 18:26:08 4: Traccar_HTTPMOD_Login: GetUpdate called (update)
2017.05.07 18:26:08 4: Traccar_HTTPMOD_Login: update timer modified: will call GetUpdate in 60.0 seconds at 2017-05-07 18:27:08
2017.05.07 18:26:08 4: Traccar_HTTPMOD_Login: AddToQueue adds update, initial queue len: 0
2017.05.07 18:26:08 5: Traccar_HTTPMOD_Login: AddToQueue adds type update to URL http://192.168.178.20:55000/api/devices?payload=[fhem,fhem], no data, no headers, retry 0
2017.05.07 18:26:08 5: Traccar_HTTPMOD_Login: HandleSendQueue called, qlen = 1
2017.05.07 18:26:08 4: Traccar_HTTPMOD_Login: HandleSendQueue sends request type update to URL http://192.168.178.20:55000/api/devices?payload=[fhem,fhem], No Data, No Header,
timeout 2
2017.05.07 18:26:08 4: HttpUtils url=http://192.168.178.20:55000/api/devices?payload=[fhem,fhem]
2017.05.07 18:26:08 5: HttpUtils request header:
GET /api/devices?payload=[fhem,fhem] HTTP/1.0
Host: 192.168.178.20:55000
User-Agent: fhem
Content-Length: 0
Content-Type: application/x-www-form-urlencoded

2017.05.07 18:26:08 4: http://192.168.178.20:55000/api/devices?payload=[fhem,fhem]: HTTP response code 415
2017.05.07 18:26:08 4: HttpUtils http://192.168.178.20:55000/api/devices?payload=[fhem,fhem]: Got data, length: 61
2017.05.07 18:26:08 5: HttpUtils response header:
HTTP/1.1 415 Unsupported Media Type
Date: Sun, 07 May 2017 16:26:08 GMT
Access-Control-Allow-Headers: origin, content-type, accept, authorization
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin: *
Content-Length: 61
Server: Jetty(9.2.21.v20170120)
2017.05.07 18:26:08 4: Traccar_HTTPMOD_Login: Read callback: request type was update retry 0,
Header: HTTP/1.1 415 Unsupported Media Type
Date: Sun, 07 May 2017 16:26:08 GMT
Access-Control-Allow-Headers: origin, content-type, accept, authorization
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin: *
Content-Length: 61
Server: Jetty(9.2.21.v20170120),
Body: HTTP 415 Unsupported Media Type - NotSupportedException (...)
2017.05.07 18:26:08 3: Traccar_HTTPMOD_Login: error while parsing JSON data: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "HTTP 415 Unsupported...") at (eval 353189) line 1.

2017.05.07 18:26:08 5: Traccar_HTTPMOD_Login: looking for Cookies in HTTP/1.1 415 Unsupported Media Type
Date: Sun, 07 May 2017 16:26:08 GMT
Access-Control-Allow-Headers: origin, content-type, accept, authorization
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin: *
Content-Length: 61
Server: Jetty(9.2.21.v20170120)
2017.05.07 18:26:08 5: Traccar_HTTPMOD_Login: ExtractSid called, context reading, num
2017.05.07 18:26:08 5: Traccar_HTTPMOD_Login: Checking SID with JSON 1ohywg1ok72dl10939tfbvtgam
2017.05.07 18:26:08 4: Traccar_HTTPMOD_Login: CheckAuth decided no authentication required
2017.05.07 18:26:08 3: Traccar_HTTPMOD_Login: no parsed JSON structure available
2017.05.07 18:26:08 5: Traccar_HTTPMOD_Login: Read starts parsing response to update with defined readings:
2017.05.07 18:26:08 3: Traccar_HTTPMOD_Login: Read response to update didn't match any Reading
2017.05.07 18:26:08 5: Traccar_HTTPMOD_Login: HandleSendQueue called, qlen = 0



Gruss Denny
HostSystem: Synology DS918 | FHEM im Docker Version: 6.0-s22528_v2.2.4 (dedizierte IP Adresse) | MQTT_Broker auf DS918 NAS | MQTT_FHEM | TASMOTA_DEVICE | SSChatBot | SSCam | LaMetric | FBAHAHTTP | CUL | SONOS | HUEBridge (deCONZ) Zigbee | FB_CALLMONITOR | InfluxDBLogger

spel

Hallo Denny,

ich nutze auch Traccar und überlege wie ich es auf das TabletUI / mein Tablet bekomme...

Ich nutzte allerdings noch nicht mysql. Wie weit bist du mittlerweile?

Danke und Gruß

Christoph

rohlande

Hi,

ich muss gestehen, dass ich es im Moment nicht verfolge.
Aber gut das Du fragst.
Denn aktuell bin ich gezwungen die GPS Position in ein FHEM dummy zu schreiben.
Das werde ich jetzt via php Script hoffentlich gelöst bekommen.
Dazu gab es wohl schon Umsetzungen. Muss mich aber erst damit befassen.
Wenn es etwas dazu gibt stelle ich es ein.

VG Denny
HostSystem: Synology DS918 | FHEM im Docker Version: 6.0-s22528_v2.2.4 (dedizierte IP Adresse) | MQTT_Broker auf DS918 NAS | MQTT_FHEM | TASMOTA_DEVICE | SSChatBot | SSCam | LaMetric | FBAHAHTTP | CUL | SONOS | HUEBridge (deCONZ) Zigbee | FB_CALLMONITOR | InfluxDBLogger

Ma_Bo

Zitat von: amenomade am 04 Mai 2017, 20:13:13
@rohlande: Dann musst du das erstmal lösen, das hat nichts mit FHEM zu tun. Ich würde sagen, dir fehlt noch etwas wie die so genannte "RestFul API" http://traccar.litvak.su/features/rest-api.html. Ohne diese API ist bestimmt eine andere Vorgehensweise zu suchen: andere URLs, usw.
So lang du keine vernünftige Vorgehensweise in einem Browser hast, brauchst Du nicht, es versuchen, in fhem zu implementieren!


@Ma_bo: kein Thema, ich bin nicht in Eile. Du bist derjenige, der an die Sache interessiert ist  ;)

Gruß

Habe es mal ausprobiert mit (nicht wundern, der IP Bereich hat sich geändert, der hier verwendete ist aktuell):

define Traccar HTTPMOD http://192.168.178.45:8082/traccar/rest/getLatestPositions 60
attr Traccar enableCookies 1
attr Traccar verbose 5
attr Traccar extractAllJSON 1
attr Traccar reAuthRegex /rest/login
attr Traccar sid1URL http://192.168.178.45:8082/traccar/rest/login?payload=[fhem,fhem]


Dann kommt im Log:

2017.07.27 16:08:26.026 4: Traccar: GetUpdate called (update)
2017.07.27 16:08:26.026 4: Traccar: update timer modified: will call GetUpdate in 60.0 seconds at 2017-07-27 16:09:26
2017.07.27 16:08:26.027 4: Traccar: AddToQueue adds update, initial queue len: 0
2017.07.27 16:08:26.027 5: Traccar: AddToQueue adds type update to URL http://192.168.178.45:8082/traccar/rest/getLatestPositions, no data, no headers, retry 0
2017.07.27 16:08:26.027 5: Traccar: HandleSendQueue called, qlen = 1
2017.07.27 16:08:26.027 5: Traccar: HandleSendQueue is adding Cookies: JSESSIONID=n3u1h96fv8gf1d4082jxtcpy6
2017.07.27 16:08:26.027 4: Traccar: HandleSendQueue sends request type update to URL http://192.168.178.45:8082/traccar/rest/getLatestPositions, No Data,
header: Cookie: JSESSIONID=n3u1h96fv8gf1d4082jxtcpy6,
timeout 2
2017.07.27 16:08:26.027 4: HttpUtils url=http://192.168.178.45:8082/traccar/rest/getLatestPositions
2017.07.27 16:08:26.030 5: HttpUtils request header:
GET /traccar/rest/getLatestPositions HTTP/1.0
Host: 192.168.178.45:8082
User-Agent: fhem
Cookie: JSESSIONID=n3u1h96fv8gf1d4082jxtcpy6
Content-Length: 0
Content-Type: application/x-www-form-urlencoded

2017.07.27 16:08:26.037 4: http://192.168.178.45:8082/traccar/rest/getLatestPositions: HTTP response code 401
2017.07.27 16:08:26.038 4: HttpUtils http://192.168.178.45:8082/traccar/rest/getLatestPositions: Got data, length: 321
2017.07.27 16:08:26.038 5: HttpUtils response header:
HTTP/1.1 401 Unauthorized
Date: Thu, 27 Jul 2017 14:08:26 GMT
Content-Type: text/html; charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 321
Server: Jetty(9.2.13.v20150730)
2017.07.27 16:08:26.038 4: Traccar: Read callback: request type was update retry 0,
Header: HTTP/1.1 401 Unauthorized
Date: Thu, 27 Jul 2017 14:08:26 GMT
Content-Type: text/html; charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 321
Server: Jetty(9.2.13.v20150730),
Body: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 401 Unauthorized</title>
</head>
<body><h2>HTTP ERROR 401</h2>
<p>Problem accessing /traccar/rest/getLatestPositions. Reason:
<pre>    Unauthorized</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>

</body>
</html>

2017.07.27 16:08:26.038 3: Traccar: error while parsing JSON data: malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "<html>\n<head>\n<met...") at (eval 8382090) line 1.

2017.07.27 16:08:26.038 5: Traccar: looking for Cookies in HTTP/1.1 401 Unauthorized
Date: Thu, 27 Jul 2017 14:08:26 GMT
Content-Type: text/html; charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 321
Server: Jetty(9.2.13.v20150730)
2017.07.27 16:08:26.038 5: Traccar: ExtractSid called, context reading, num
2017.07.27 16:08:26.039 5: Traccar: CheckAuth is checking buffer with ReAuthRegex /rest/login
2017.07.27 16:08:26.039 4: Traccar: CheckAuth decided no authentication required
2017.07.27 16:08:26.039 3: Traccar: no parsed JSON structure available
2017.07.27 16:08:26.039 5: Traccar: UpdateReadingList created list of reading.* nums to parse during getUpdate as
2017.07.27 16:08:26.039 5: Traccar: Read starts parsing response to update with defined readings:
2017.07.27 16:08:26.039 3: Traccar: Read response to update didn't match any Reading
2017.07.27 16:08:26.039 5: Traccar: HandleSendQueue called, qlen = 0
2017.07.27 16:09:26.027 4: Traccar: GetUpdate called (update)
2017.07.27 16:09:26.028 4: Traccar: update timer modified: will call GetUpdate in 60.0 seconds at 2017-07-27 16:10:26
2017.07.27 16:09:26.028 4: Traccar: AddToQueue adds update, initial queue len: 0
2017.07.27 16:09:26.028 5: Traccar: AddToQueue adds type update to URL http://192.168.178.45:8082/traccar/rest/getLatestPositions, no data, no headers, retry 0
2017.07.27 16:09:26.028 5: Traccar: HandleSendQueue called, qlen = 1
2017.07.27 16:09:26.029 5: Traccar: HandleSendQueue is adding Cookies: JSESSIONID=n3u1h96fv8gf1d4082jxtcpy6
2017.07.27 16:09:26.029 4: Traccar: HandleSendQueue sends request type update to URL http://192.168.178.45:8082/traccar/rest/getLatestPositions, No Data,
header: Cookie: JSESSIONID=n3u1h96fv8gf1d4082jxtcpy6,
timeout 2
2017.07.27 16:09:26.029 4: HttpUtils url=http://192.168.178.45:8082/traccar/rest/getLatestPositions
2017.07.27 16:09:26.031 5: HttpUtils request header:
GET /traccar/rest/getLatestPositions HTTP/1.0
Host: 192.168.178.45:8082
User-Agent: fhem
Cookie: JSESSIONID=n3u1h96fv8gf1d4082jxtcpy6
Content-Length: 0
Content-Type: application/x-www-form-urlencoded

2017.07.27 16:09:26.039 4: http://192.168.178.45:8082/traccar/rest/getLatestPositions: HTTP response code 401
2017.07.27 16:09:26.039 4: HttpUtils http://192.168.178.45:8082/traccar/rest/getLatestPositions: Got data, length: 321
2017.07.27 16:09:26.039 5: HttpUtils response header:
HTTP/1.1 401 Unauthorized
Date: Thu, 27 Jul 2017 14:09:26 GMT
Content-Type: text/html; charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 321
Server: Jetty(9.2.13.v20150730)
2017.07.27 16:09:26.039 4: Traccar: Read callback: request type was update retry 0,
Header: HTTP/1.1 401 Unauthorized
Date: Thu, 27 Jul 2017 14:09:26 GMT
Content-Type: text/html; charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 321
Server: Jetty(9.2.13.v20150730),
Body: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 401 Unauthorized</title>
</head>
<body><h2>HTTP ERROR 401</h2>
<p>Problem accessing /traccar/rest/getLatestPositions. Reason:
<pre>    Unauthorized</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>

</body>
</html>

2017.07.27 16:09:26.039 3: Traccar: error while parsing JSON data: malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "<html>\n<head>\n<met...") at (eval 8382883) line 1.

2017.07.27 16:09:26.040 5: Traccar: looking for Cookies in HTTP/1.1 401 Unauthorized
Date: Thu, 27 Jul 2017 14:09:26 GMT
Content-Type: text/html; charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 321
Server: Jetty(9.2.13.v20150730)
2017.07.27 16:09:26.040 5: Traccar: ExtractSid called, context reading, num
2017.07.27 16:09:26.040 5: Traccar: CheckAuth is checking buffer with ReAuthRegex /rest/login
2017.07.27 16:09:26.040 4: Traccar: CheckAuth decided no authentication required
2017.07.27 16:09:26.040 3: Traccar: no parsed JSON structure available
2017.07.27 16:09:26.040 5: Traccar: Read starts parsing response to update with defined readings:
2017.07.27 16:09:26.040 3: Traccar: Read response to update didn't match any Reading
2017.07.27 16:09:26.040 5: Traccar: HandleSendQueue called, qlen = 0


List vom Traccar:

Internals:
   .getList
   .setList
   BUSY       0
   CFGFN
   CHANGED
   DEF        http://192.168.178.45:8082/traccar/rest/getLatestPositions 60
   HTTPCookies JSESSIONID=n3u1h96fv8gf1d4082jxtcpy6
   Interval   60
   JSONEnabled 1
   LASTSEND   1501164801.29707
   MainURL    http://192.168.178.45:8082/traccar/rest/getLatestPositions
   ModuleVersion 3.3.11 - 8.5.2017
   NAME       Traccar
   NR         411808
   STATE      ???
   TRIGGERTIME 1501164861.29623
   TRIGGERTIME_FMT 2017-07-27 16:14:21
   TYPE       HTTPMOD
   addr       http://192.168.178.45:8082
   buf
   code       401
   conn
   data
   displayurl http://192.168.178.45:8082/traccar/rest/getLatestPositions
   header     Cookie: JSESSIONID=n3u1h96fv8gf1d4082jxtcpy6
   host       192.168.178.45
   httpheader HTTP/1.1 401 Unauthorized

Date: Thu, 27 Jul 2017 14:13:21 GMT

Content-Type: text/html; charset=ISO-8859-1

Cache-Control: must-revalidate,no-cache,no-store

Content-Length: 321

Server: Jetty(9.2.13.v20150730)
   httpversion 1.0
   hu_blocking 0
   hu_filecount 8
   hu_portSfx :8082
   ignoreredirects 0
   loglevel   4
   path       /traccar/rest/getLatestPositions
   protocol   http
   redirects  0
   timeout    2
   url        http://192.168.178.45:8082/traccar/rest/getLatestPositions
   value      0
   .readingParseList:
   Httpcookiehash:
     Jsessionid:
       Options    Path=/

       Value      n3u1h96fv8gf1d4082jxtcpy6
   QUEUE:
   Readings:
   Request:
     data
     header
     ignoreredirects 0
     retryCount 0
     type       update
     url        http://192.168.178.45:8082/traccar/rest/getLatestPositions
     value      0
   Sslargs:
Attributes:
   enableCookies 1
   extractAllJSON 1
   reAuthRegex /rest/login
   sid1URL    http://192.168.178.45:8082/traccar/rest/login?payload=[fhem,fhem]
   userattr   sid1URL
   verbose    5



Wenn ich das im Browser abrufe:

http://192.168.178.45:8082/traccar/rest/login?payload=[fhem,fhem]

erhalte ich (teilweise Werte mit xxxx ersetzt):

{"id":2,"login":"fhem","password_hash_method":"MD5","admin":true,"manager":false,"userSettings":{"speedUnit":"kilometersPerHour","timePrintInterval":1,"zoomLevel":18,"centerLongitude":xxxx,"centerLatitude":xxxx,"mapType":"GOOGLE_HYBRID"},"readOnly":false,"archive":true}

wenn ich das dann im Browser abrufe:

http://192.168.178.45:8082/traccar/rest/getLatestPositions

erhalte ich alle Werte korrekt im Browser (teilweise Werte mit xxxx ersetzt):

[{"id":8336795,"device":{"id":1,"uniqueId":"xxxx","name":"Deaktiviert","timeout":300,"idleSpeedThreshold":0.0,"iconType":{"OFFLINE":{"width":53,"height":20,"urls":["img/sedan-white.png","img/sedan-green.png"]},"LATEST":{"width":53,"height":20,"urls":["img/sedan-red.png","img/sedan-green.png"]}}},"time":"Thu, 18 May 2017 12:54:18 +0200","valid":true,"latitude":xxxx,"longitude":xxxx,"altitude":xxxx,"speed":0.0,"course":148.83218383789062,"other":"{\"battery\":\"100.0\",\"ip\":\"xxxx\"}","protocol":"osmand","serverTime":"Fri, 19 May 2017 17:25:58 +0200"},{"id":9387104,"device":{"id":2,"uniqueId":"xxxx","name":"C220","timeout":300,"idleSpeedThreshold":0.0,"iconType":{"OFFLINE":{"width":53,"height":20,"urls":["img/sedan-white.png","img/sedan-green.png"]},"LATEST":{"width":53,"height":20,"urls":["img/sedan-red.png","img/sedan-green.png"]}}},"time":"Thu, 27 Jul 2017 16:18:59 +0200","valid":false,"latitude":xxxx,"longitude":xxxx,"altitude":64.0,"speed":0.0,"course":262.0,"other":"{\"sat\":2,\"event\":\"2\",\"input\":\"4210\",\"ip\":\"xxxx\"}","protocol":"wondex","serverTime":"Thu, 27 Jul 2017 16:19:01 +0200"},{"id":8842182,"device":{"id":3,"uniqueId":"xxxx","name":"MaBo iPhone","timeout":300,"idleSpeedThreshold":0.0,"iconType":{"OFFLINE":{"width":12,"height":20,"urls":["img/phone-white.png","img/phone-green.png"]},"LATEST":{"width":12,"height":20,"urls":["img/phone-red.png","img/phone-green.png"]}}},"time":"Wed, 21 Jun 2017 16:00:58 +0200","valid":true,"latitude":xxxx,"longitude":xxxx,"altitude":54.6765,"speed":0.0,"course":0.0,"other":"{\"battery\":\"78\",\"ip\":\"xxxx\"}","protocol":"osmand","serverTime":"Wed, 21 Jun 2017 16:01:54 +0200"}]
NUC mit FHEM, HM Heizungsthermostate, HM Wandthermostate, Intertechno Funksteckdosen, 10" Tablet als Wanddisplay, KeyMatic, Fensterkontakte, Fensterkontakte umgebaut als Wassermelder und Briefkastenmelder, Aussenthermostat, Anwesenheitssteuerung über Fritz Box, Google Home usw. usw.

amenomade

Also...

Der Versuch, getLatestPositions aufzurufen leitet nicht nach die Authentifizierungsseite weiter, sondern ergibt HTTP 401 "Unauthorized".
Dann kommt die Regex im Einsatz
attr Traccar reAuthRegex /rest/login
ZitatCheckAuth is checking buffer with ReAuthRegex /rest/login
Da in der HTTP401 Unauthorized Seite keine "/rest/login" zu finden ist, sagt HTTMOD
ZitatCheckAuth decided no authentication required
Und Schluss

Ich würde einfach reAuthRegex ändern, damit es auf z.B. "Unauthorized" geprüft wird
attr Traccar reAuthRegex Unauthorized
Damit sollte er sehen, dass er nicht authentifiziert ist, und deswegen sid1URL  aufrufen.
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Ma_Bo

Das Probier ich heute Nachmittag aus.

Danke für deine Hilfe.


Tapatalk mit Handy geschrieben, daher kurz gehalten.
NUC mit FHEM, HM Heizungsthermostate, HM Wandthermostate, Intertechno Funksteckdosen, 10" Tablet als Wanddisplay, KeyMatic, Fensterkontakte, Fensterkontakte umgebaut als Wassermelder und Briefkastenmelder, Aussenthermostat, Anwesenheitssteuerung über Fritz Box, Google Home usw. usw.

Ma_Bo

#28
MEGA, es funktioniert !

Jetzt muss ich nur noch schauen, dass ich nur die Readings bekomme, die ich brauche.

Grüße Marcel


#####EDIT

Ist doch ganz gut, dass ich ALLE Readings direkt in einem device habe...  ;D
NUC mit FHEM, HM Heizungsthermostate, HM Wandthermostate, Intertechno Funksteckdosen, 10" Tablet als Wanddisplay, KeyMatic, Fensterkontakte, Fensterkontakte umgebaut als Wassermelder und Briefkastenmelder, Aussenthermostat, Anwesenheitssteuerung über Fritz Box, Google Home usw. usw.

rohlande

@Ma_Bo:  welche Version hast Du installiert? Bin in der Zwischenzeit auf einen Debian Server umgezogen. Nur leider scheint bei der aktuellen Version auch kein RestFul Api zu laufen oder ich mache einen Fehler?

VG Denny
HostSystem: Synology DS918 | FHEM im Docker Version: 6.0-s22528_v2.2.4 (dedizierte IP Adresse) | MQTT_Broker auf DS918 NAS | MQTT_FHEM | TASMOTA_DEVICE | SSChatBot | SSCam | LaMetric | FBAHAHTTP | CUL | SONOS | HUEBridge (deCONZ) Zigbee | FB_CALLMONITOR | InfluxDBLogger