The "The Things Network" import panel should ask for; Zone, Application, API Key. Poll Interval to be selected.
Upon submitting that, The Things Network should be queried for all the devices in that zone/application, and listed with checkbox selector so one can choose which devices to be imported. Poll Interval can be overridden from the above.
For each selected device, another request to TTN to retrieve the latest packets, and get hold of the "$.upload_message.decoded_payload" object, which contains the data points that we might want. Again with selection of those, and each selected one can have an overridden Poll Interval, then plus Scaling and Unit.
Quite complex, but can be very useful to capture customers who use Things Network.
To access The Things Network, the following two URLs are most interesting;
The Authorization Key is via the http header
Authorization: Bearer {{authkey}}
Tests can be made with;
Zone; eu1
Application; l2w-test-app
Auth Key; NNSXS.6SND4GB4FKKJMWSMAR3PPX7TUPTWBLV7UOLCQMY.QAJ6D57MSZH4KXXOOV2NJYT3CWPEDG2UG7ORWDV2PXFMC63H2JDA
One important aspect is that there are more than one so called f_port and that needs to be configured to Sensetif. So when reading packets, it is important to both show thef_port and let the user select packets for a given f_port number. (On the devices that are on the l2w-test-app then f_port=2)
And inside there are the f_port and decoded_payload. decoded_payload contains the names of interest. This is totally user defined, and potentially could be full JSON objects, rather than primitive values, but let's require only primitive values initially, i.e. IF there is an Object, show the name, but disallow selection on it, and the REASON in hover-over/tooltip.
I imagine this;
Select Zone (one of eu1 (Europe), nam1 (North America) or au1 (Australia)), application, poll interval, and if each device should become its own subsystem, or be added to an existing subsystem and device+variable merged in the datapoint name with an underscore ("_")
Fetch Devices with a Button press, and fill a list to the left with device names.
Select which devices should be part of the Import. For each device, be able to select "Device Template" or create a new one (see below). Maybe default is "No Template", in which case the device will be left out of the import.
Validate; Fetch stored data and make sure that the Template matches the devices selected.
For each Device, for each variable in template, create a data point definition, either by creating a subsystem per device and adding datapoints in that subsystem with the same variable names, or creating datapoints with a concatenated name (device + "_" + varName) in the selected subsystem. If subsystems are to be created, create subsystems first, then wait 2 seconds and continue with the data points.
Create Device Template popup(?); Fetch the stored data for the device, present the variable names in a list to the left, and the min, max, unit and scaling. (I have not decided on storage period yet. Probably going to remove it from datapoints and always use "account wide" storage periods). Template also needs a name.
I think it is important to minimize "waiting" in UI thread.
The "The Things Network" import panel should ask for; Zone, Application, API Key. Poll Interval to be selected. Upon submitting that, The Things Network should be queried for all the devices in that zone/application, and listed with checkbox selector so one can choose which devices to be imported. Poll Interval can be overridden from the above.
For each selected device, another request to TTN to retrieve the latest packets, and get hold of the "$.upload_message.decoded_payload" object, which contains the data points that we might want. Again with selection of those, and each selected one can have an overridden Poll Interval, then plus Scaling and Unit.
Quite complex, but can be very useful to capture customers who use Things Network.
To access The Things Network, the following two URLs are most interesting;
Devices Api;
https://{{zone}}.cloud.thethings.network/api/v3/applications/{{application_id}}/devices
Storage Api;
https://{{zone}}.cloud.thethings.network/api/v3/as/applications/{{application_id}}/devices/{{device_id}}/packages/storage/uplink_message
The Authorization Key is via the http header
Authorization: Bearer {{authkey}}
Tests can be made with; Zone;
eu1
Application;l2w-test-app
Auth Key;NNSXS.6SND4GB4FKKJMWSMAR3PPX7TUPTWBLV7UOLCQMY.QAJ6D57MSZH4KXXOOV2NJYT3CWPEDG2UG7ORWDV2PXFMC63H2JDA
One important aspect is that there are more than one so called
f_port
and that needs to be configured to Sensetif. So when reading packets, it is important to both show thef_port
and let the user select packets for a givenf_port
number. (On the devices that are on thel2w-test-app
thenf_port=2
)With the following request;
one should get something like this;
And requesting
will bring back a stream of json packets, separated by LineFeed. NOTE: Not a valid single json document.
Showing the last 3 results;
And inside there are the
f_port
anddecoded_payload
.decoded_payload
contains the names of interest. This is totally user defined, and potentially could be full JSON objects, rather than primitive values, but let's require only primitive values initially, i.e. IF there is an Object, show the name, but disallow selection on it, and the REASON in hover-over/tooltip.I imagine this;
Create Device Template popup(?); Fetch the stored data for the device, present the variable names in a list to the left, and the min, max, unit and scaling. (I have not decided on storage period yet. Probably going to remove it from datapoints and always use "account wide" storage periods). Template also needs a name.
I think it is important to minimize "waiting" in UI thread.