How to simulate a real device behavior?

An easy way to generate messages for a flespi device to test and debug plugins, streams, calculators, etc.

If you need to initiate activity for your device but can’t force it to send messages, you can generate a message manually in flespi. Below is a simple step-by-step guide on how to do that.

1. Copy a message

To make sure you post a message in the right format, open Logs & Messages tab for your device, click on any previously sent message and copy it in JSON format.

toolbox copy message json

2. Post a message

Use the https://flespi.io/docs/#/gw/devices/post_devices_dev_selector_messages request (the link will open in the APIbox tool) and paste the copied message JSON into the DATA section. Make any edits to the JSON if needed (we changed the position.speed parameter value to 100 for testing) and execute the request:

apibox paste message json

Note: you can automate the request execution by writing a basic script that will perform this request with the specified frequency and with edits to specific message parameters (if necessary). 

3. Check message receipt

Now go back to the Logs & Messages tab for your device and check if the new message has arrived.

toolbox check generated message

Everything looks correct. 

By generating messages when you need them you can test dependent or related items such as plugins, streams, or calculators.

Specifics

The simulated message is different from the real message sent by the device in the following aspects:

  • It has a ‘rest.timestamp’ parameter (generated automatically upon request execution).

  • It doesn’t have ‘server.timestamp’ and ‘channel.id’ parameters.


See also
Using plugins to resolve position coordinates into address using Here reverse geocoding API and add it into the device messages.