Automatically translate this page?

How to get the last state of a registered device?

Getting device telemetry via REST API and in the flespi panel.

In some tasks, you don’t need to continuously receive messages from your device. But just get its state and last value of all parameters to answer the questions like:

  1. What was the last position of my device?

  2. When was the device online last time?

  3. What was the last value of the given sensor and when was it updated?

Telemetry is a structure that analyses each new message received by the registered device and stores the last value of each parameter and time when it was received. Following is the principle of device telemetry operation.

device telemetry scheme in flespi device

You can get telemetry via the appropriate REST API call. Telemetry will be returned as an object where the key is a parameter name, value is an object with fields value, and ts is a timestamp when the value was updated, e.g. 

     "telemetry": {
        "channel_id": {
          "ts": 1540982367,
          "value": 3300
        "chat_id": {
          "ts": 1540982367,
          "value": 168488620

It is a good practice to obtain telemetry over MQTT API:

  • Subscribe to topic flespi/state/gw/devices/{device-id}/telemetry/+
  • Receive current Telemetry as a retain message.
  • Receive updated value for every parameter each time it changes. ( With MQTT 5.0 the timestamp of parameter being updated is transmitted in MQTT message user properties.)

Telemetry can be viewed in TrackIt:

trackit telemetry

or the Telemetry device tab:

telemetry device tab

With telemetry feature, you don’t need to recall the latest messages to get device’s last state.

Please be aware that device telemetry values are actual for 30 days only. It means that if device did not updated some parameters in 30 days these parameters will disappear automatically from telemetry.

Also, check telemetry article on our blog.

See also
The guide on how to set up a calculator to receive live customizable MQTT messages when device parameters change according to a complex condition.
Handling events, accessing intervals, and attaching custom data to calculators