Your online gateway inside the The Things Network can be monitored. A predefined url including the gateway ID/name can be loaded into an url. The output will be in the JSON format.
All registered gateways can be found on a map: https://www.thethingsnetwork.org/map. Use the zoom buttons on the left to locate for example your gateway or find a gateway nearby. You may click on the blue balloons in to map itself a swell to go to the desired location.
Gateway ID’s or names are unique, but not hidden or secret. Instead of monitoring your own gateway, you can do the same with a random one (in your neighbourhood for example). In case you own a gateway I suggest to get your ID/name from the The Things Network console.
The predefined url to monitor a gateway is “http://noc.thethingsnetwork.org:8085/api/v2/gateways/”. At the end of the url, the gateway ID/name should be entered. My personal gateway ID/name is “rutg3rttngw”, so in the end the url will be “http://noc.thethingsnetwork.org:8085/api/v2/gateways/rutg3rttngw”. When you load this url in a browser, the output will be shown in JSON format:
{
timestamp: “2018-12-04T23:35:25.676950209Z“, authenticated: true, uplink: “2118“, location:
{
latitude: 51.37195, longitude: 6.1703496, altitude: 20, source: “REGISTRY”},
frequency_plan: “EU_863_870“, platform: “The Things Gateway v1 – BL r2-c463e87e (2018-02-23T14:42:40Z) – Firmware v1.0.5-fa89b993 (2018-07-17T08:11:52Z)“, gps:
{
latitude: 51.37195, longitude: 6.1703496, altitude: 20, source: “REGISTRY”},
time: “1543966525676950209”, rx_ok: 2118}
Every object in the JSON output can be retrieved. The uplink” in the 3rd row means how many messages are received by the gateway, in this case 2118.
The red marked values are retrieved in the script. With the first run of the script the object names and values are retrieved and virtual devices are created in Homeseer. When every other update, only the virtual devices are updated when necessary.
When the url is not able to retrieve the data from the gateway, the following JSON output is generated:
{
error: “status not found”, code: 5}
No extra checks are added yet for “Online/Offline” status, or for example a “Last seen” timespan.
Create an recurring event in Homeseer and run the script script which can be downloaded at the bottom of this page.
When the gateway url is valid, the following virtual devices will be created automatically:
Release Notes
07-12-2018 | v1.1 |
|
05-12-2018 | v1.0 |
|
Downloads:
TTN_GW_Monitoring.vb (7.3 KiB, 1,410 hits)
Related Posts
August 19, 2018
The Things Network – 8 channel LoRa gateway on Raspberry Pi
March 14, 2017
Sonoff GPIO input
October 9, 2016