We’re currently working on a project involving a TRB143 as a gateway for energy meter remote measurements. Two+ meters are queried via M-BUS, whereas an additional meter is measured via its impulse output (i.e. 1000imp/KWh).
Data is sent via “Data to Server” functionality to a remote HTTPS websocket. We’ve added to the collection the M-BUS readings and can successfully receive all current measurement values.
The issue lies on the impulse counter - if we add “Impulse counter” as data type, only the number of pulses detected between two successive sends are actually being sent, and not the total count present in “Input/Output → Impulse Counter”. If no pulses detected, empty value is sent instead.
As such, we have two questions:
How can we send the current total impulse count via “Data to Server”?
There was a similar question at “t/rut906-impulsecounter/12060”, but we couldn’t find your official Lua API documentation regarding custom data to server input.
Is it possible to always send the last known value each time the “Data to Server” periodic send is triggered, regardless of its age?
As of now, if a new value is measured (for eg. via periodic M-BUS readout), the data send is the latest; if no new data is present (for eg. M-BUS readout period higher than data to server send period), then value sent is the one set by us at “Empty value”.
Regarding LUA Scripts, they fall under the “Custom script” category, which we, as technical support, are unable to provide support with, as it is out of our scope. Impulse counters can actually be received via API: https://developers.teltonika-networks.com/reference/TRB143/7.16.2/v1.8.3/impulse-counter
And the received information can then be forwarded via the use of LUA Scripts, this is where I can’t unfortunately provide more insight.
Impulse counter stores the counts to database in 1 minute intervals by design. So data sender periods shorter than 1 minute wont send anything extra as there is no data to be sent. “The same value is not being sent periodically every 10 seconds as configured” - I don’t believe data sender instance ever sends the same data multiple times, it only looks for unsent new data (every 10 seconds in this case).
I understand “Custom script” is out of scope, as it is specific to each application.
Still, it is a feature available to the user, so is it possible to give a link to your API documentation? I’ve only found the ones you’ve linked, but those cover the REST API - I also wish to know how a Lua script may actually trigger a REST request in general, not for this specifc application.
As I understood, sending only new data is the default implementation. In this case, I need to take care on the receiving side (websocket server) to ignore “empty values”, and count all others.
I’ve consulted regarding your question about triggering a request with ChatGPT, and the response I got was: local handle = io.popen("wget -qO- 'http://localhost/api/endpoint'") local result = handle:read("*a") handle:close()
Once again, not sure whether this is the optimal way to go about things in regards to LUA scripts & API calls, but it’s worth a shot.