...
The Device Simulator functionality allows you to add devices from our catalog to an account and use them as if they were real hardware. Everything about the process is the same as real hardware - readings can be triggered, configured alerts will fire, device history is the same, etc.
...
Table of Contents |
---|
Set Simulator flag enabled
Info |
---|
Before a device will appear in the list of simulated devices, it must be enabled in the Device Template. |
To allow a device to appears in the list of simulated devices, add the allow_simulator
= true Attribute in the template.
...
Sample Payloads
By default, simulated devices will pull randomly from available data points based on the device type. So if a device type is popular, you may not need to add simulated payloads - it will magically work.
...
There are two sample_payloads allowed:
(Preferred) Hex payloads
Grabbing real payloads from devices is the best way to provide sample data. The only downside here is that you need to be able to find good examples from real devices - it’s not as easy to make them up or slightly tweak them than it is with say the JSON alternative (see below).
Code Block |
---|
[ { "format": "hex", "payload": "0300b00300b9" }, { "format": "hex", "payload": "0500b00300b9" }, { "format": "hex", "payload": "0201E01B01A5" } ] |
Decoded JSON
If you cannot use raw hex payloads, you can send decoded data that matches the appropriate data as well.
...
Code Block |
---|
[ { "format": "json", "ignore_codec": true, "payload": [ { "channel": 5, "type": "batt", "unit": "p", "name": "Battery", "value": 88 }, { "channel": 506, "type": "co2", "unit": "ppm", "name": "CO2", "value": 250 } ] }, { "format": "json", "ignore_codec": true, "payload": [ { "channel": 5, "type": "batt", "unit": "p", "name": "Battery", "value": 28.57 }, { "channel": 506, "type": "co2", "unit": "ppm", "name": "CO2", "value": 500 } ] } ] |
FAQs
Must I enable Simulator and add Payloads?
Technically, no. Enabling the simulator flag is the only requirement. But in adding devices to the simulator, QA found that very few devices had enough live data to get away with adding the flag only.
Note |
---|
After enabling a device in the simulated device list, be sure to add it into an account. If you find that it says ‘Waiting on data’ after being added, that’s an indication that you need to add sample payloads before calling it ready for customers. Another good indicator that samples are needed is if you click the Update button a few times and nothing changes (or it’s so subtle it won’t be noticed easily). |
How to locate sample payloads from the codec
You can either dig through Kibana logs or possibly you can grab samples (if they exist) from the codec directly.
...
Search for the template in Device Templates on Console.
Make note of the Codec ID
Open the Codec Editor (Super Admin)
Click on Library button
Search for the library and the click the Edit icon
IF there are sample payloads, they will be at the top of the codec.
Clicking on Update Data button in UI doesn’t update reading
Device may not have sample payloads - There may no longer be enough live data to pull from. In this case look to see if sample_payloads is defined in the Template. If not, add it with good data that can always be pulled from [Shramik currently handling this].
Sample readings are random, can be duplicated - The data pulled for the sample (whether live or sample) is random. This means it is entirely possible the same data can be pulled multiple times even though you’ve clicked the button. There is an enhancement request for this [See eptak’s list of tasks] where we want the sample payloads to be sent in order, one after another when provided.
Special Case: BLE / Beacons required (requires_template_id)
Info |
---|
We added this to solve the ‘Beacon also needs to be present’ scenario, but one could imagine we’ll have more situations where a device won’t work unless ‘this or that is also present’ that will need to be solved as well. |
...