Logic Machine Forum
Traccar as "nil value" - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Traccar as "nil value" (/showthread.php?tid=5506)



Traccar as "nil value" - PolymorphedCust - 10.07.2024

Hi

I tried making the Traccar location-script working, but ended up with an error log that stated:
User script:3: attempt to index global 'traccar' (a nil value)

I followed the instruction as much as I could ( Geolocalization with LM based on Traccar service | Logic Machine platform for KNX/EIB, EnOcean, Modbus, DALI, BacNet (openrb.com)

Furthermore, I'd like to try to make a script so that, when I leave "home", I get a message via Telegram. I do believe, when the traccar scripts are up and running, this might be fixed.

Hope you can help

Thanks in advance!


RE: Traccar as "nil value" - admin - 11.07.2024

The scheduled script is missing require('user.traccar') at the top. But it probably won't work anyway because this example is very old.
Traccar has a Telegram notification feature out of the box so LM is not needed for this: https://www.traccar.org/notifications/#telegram


RE: Traccar as "nil value" - PolymorphedCust - 12.07.2024

So the geolocation via Traccar doesn't work anymore?
Is there any other solution?
The telegram message was only for testing if it worked. The purpose is for knowing when i was home or not, for several features in my coding.


RE: Traccar as "nil value" - admin - 12.07.2024

It can work but the script must be modified according to current Traccar API. Another thing that it uses demo server which is not meant to be used for such integration. So you will either have to run a Traccar instance on your own server or use a paid account.

A possible solution for home/away detection is to get the WiFi registration table from your router. We have a working example for MikroTik devices: https://kb.logicmachine.net/integration/mikrotik/#example