Are there server hooks?

realnumber9 years ago

I want to use traccar server to store location data in mysql server. However,i deem it desirable to have an after or before insertion so as to feed such data to redis or mongodb.

Does traccar have such a facility?.

Anton Tananaev9 years ago

You can probably use forward.url configuration parameter to send data to some service or script that will do what you want.

jaimzj9 years ago

Dear Anton,

If I was to configure forward.url in traccar config file will it forward all data to a script/service?

can you show/share any link/documentation or examples please.

Anton Tananaev9 years ago

You can enable it in the config file like this:

<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://example.com:8080/gprmc/Data?id={uniqueId}&amp;code=0x0000&amp;gprmc={gprmc}</entry>

For list of available parameters it's better to look at the source code:
https://github.com/tananaev/traccar/blob/master/src/org/traccar/WebDataHandler.java#L75

If something that you need is missing, I can add more parameters.

realnumber9 years ago

Thanks Anton. You saved me a lot of time.

realnumber9 years ago

Many thanks. I shall try it out.

jaimzj9 years ago

Anton,

Having come to know of this forward.url feature, And wanting to try to use it to achieve some thoughts I have.

Will this feature be there in the future releases as well, any possibility of depreciation?

As I am using my own (Web App) along with default Traccar Server engine without any changes on server.

I was thinking of now using forward.url to implement check on each position stored by server (To store alarms/alerts etc.) basically I am thinking of creating a web service/script which will every-time check the input data from forward.url (Recieved) and check for set filters/conditions etc.

Would it be the right approach?

Anton Tananaev9 years ago

There are no plans to deprecate or remove the feature.

As for alerts, I plan to implement it in the next release.

jaimzj9 years ago

Okay sounds great, Also for alerts I think API would be a "bonus" if available, specially for users like me who have web-app of own..

Steini0079 years ago

Hi Anton,

the forward.url functionality works perfectly in my scenario and helps me a lot to integrate my GPS tracker in my house automation environment.

The only thing I am missing is the information regarding the charge of the battery of my GPS tracker.
I have a TK5000 device, which uses the wondex protocol. The wondex protocol includes the information regarding the charge of the battery, therefore I am wondering, wether you could add this information to the forward.url functionality (I know, that not all protocols have that information ...)?

Thank you in advance,
steini

Anton Tananaev9 years ago

@steini007, do you have protocol documentation for your device?

Steini0079 years ago

Hi Anton,

no, I do not have the protocol documentation of my device.

I was refering to the wondex protocol (https://dl.dropboxusercontent.com/s/f0lg6ombf8d26pb/Part%20of%20VT300%20Protocol%20Document%20V101%20%2820110310%29.pdf) which is linked on the traccar.org site https://www.traccar.org/protocols/
I thought, that this protocol is a kind of standard and therefore it is the same for all devices, which uses the wondex protocol. Maybe this assumption was wrong?!

If you have a tipp, how I can found out, how the returning message of my device looks like, just let me know.

Thank you,
steini

Anton Tananaev9 years ago

I looked through the document and it doesn't seem like it's reporting battery info.

Steini0079 years ago

I used a sniffer tool to check the data transfer between the device and traccar and it seems, that the battery info is not included. Unfortunately ...
Nevertheless, thank you for your support and for the great tool :-)

maitret8 years ago

Excelente ayuda con los WebHooks, solo recomiendo tener ambos servidores "cerca" por la gran cantidad de datos que se van a estar transfiriendo. :v

Les dejo mi configuracion con todos los campos disponibles: =D

<entry key='forward.enable'>true</entry>
<entry key='forward.url'>https://yourdomain.com/apps/test/webhook.php?id={uniqueId}&deviceId={deviceId}&valid={valid}&fixTime={fixTime}&deviceTime={deviceTime}&protocol={protocol}&name={name}&latitude={latitude}&longitude={longitude}&altitude={altitude}&speed={speed}&course={course}&statusCode={statusCode}&address={address}&gprmc={gprmc}&attributes={attributes}</entry>

WeHook.php:

<?php
$data_json = json_encode($_REQUEST);
mail("maitret@myhostmx.com", $_SERVER['PHP_SELF'], $data_json);
?>

Y recibo algo como esto:

{"id":"00000IMEI00000","deviceId":"1","valid":"true","fixTime":"1480791433000","deviceTime":"1480791433000","protocol":"gps103","name":"U171","latitude":"22.223115","longitude":"-97.86443","altitude":"0.0","speed":"0.0","course":"0.0","statusCode":"0xF020","address":"SN-S ESTACIONAMIENTO ARTELI Plutarco Elias Calles, Tampico, Tamps., MX","gprmc":"$GPRMC,185713.000,A,2213.3869,N,09751.8658,W,0.00,0.00,031216,,*10","attributes":"{\"ip\":\"201.166.178.29\",\"distance\":0.0,\"totalDistance\":46050.47}"}