Get gateway status with node-red

Hello Everyone,
Trying to get my gateway status using node-red (get request)
Can someone please point me what i am doing wrong ?
Looks something wrong with credential , but i dont know from where to get token id - of course it that the case of issue…

I think i am bit closer, now i getting 403 error which is - "error:pkg/auth/rights:no_gateway_rights (no rights for gateway eui.....l)

My question is how to grant access to that gateway ?
Anyone can help please ?

Have you created an API key? That should have access rights which you can update to include these rights.

Hi Jac,

Yes i have - my Bearer looks as follow Bearer NNSXS.XXXXXX.XXXXXX .
What else could couse error ?

The Key ID is not the API token, when you created the token you should have gotten a message telling you to save it because it could not be retrieved later on. If you no longer have that token you will need to create a new one. That token is what is required in the request,

Hi @kersing

Here is what i doing now , using key picture and still some issue.
Probably token i should generate somehere else…i am new here so sorry if asking such easy question

That looks right, however I sometimes have issues when using the copy button so I usually display the key and use select-all and copy of the contents of the text field.

What I use in node-red is:
In a function set:

msg.headers = {
    Authorization: "Bearer NNSXS.3W5...."
}

For the HTTP node use GET with URL (for community network):

https://eu1.cloud.thethings.network/api/v3/gs/gateways/{{{payload}}}/connection/stats

where {{{payload}}} expands to the gateway ID.

Here are some nodes that I have used for years now. You can copy it and replace the gatewayID and key with the one you get from console in the inject-node:

[{"id":"931b4c60cdd10c5c","type":"inject","z":"a3002ce96bc86580","name":"gateway data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"300","crontab":"","once":true,"onceDelay":"32","topic":"","payload":"{\"gatewayID\":\"eui-0000123456789012\",\"key\":\"NNSXS.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\"}","payloadType":"json","x":280,"y":400,"wires":[["4a35cfa3.f64b"]]},{"id":"4a35cfa3.f64b","type":"function","z":"a3002ce96bc86580","name":"Compose request","func":"var apiURLPrefix = \"https://eu1.cloud.thethings.network/api/v3/gs/gateways/\";\nvar apiURLSuffix = \"/connection/stats\";\nmsg.url = apiURLPrefix + msg.payload.gatewayID + apiURLSuffix;\nmsg.headers = {\n    Authorization: \"Bearer \" + msg.payload.key\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":400,"wires":[["ed06ff60.b7151"]]},{"id":"ed06ff60.b7151","type":"http request","z":"a3002ce96bc86580","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":650,"y":400,"wires":[["a8c372134311c142"]]},{"id":"a8c372134311c142","type":"debug","z":"a3002ce96bc86580","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":800,"y":400,"wires":[]}]

Enjoy!

I am interested in this as well, quick question, Is the URL for Australian Gateways the same, but with au1.cloud etc.Where can I see this address when I am looking at my gateway in TTN?

Front & centre on your gateway page when you select it from the list!

@pe1mew, I am interested in this, never knew I could do this, and I used your flow and I am getting data back. How do I use it to monitor the status? Is there a specific part of the message that I need to look for or just the fact I get a message enough?

The best thing you can do is study the payload data and switch your gateway in and off. You rapidly find out what to look for.

I think I am doing something wrong. I keep getting posts even though I powered the gateway off and they look the same. I have this message in the payload " error:pkg/ttnpb:identifiers (invalid identifiers)" and a few other what look to be errors. What I did was create an API for my gateway, copy the token, then updated the first node in your flow to specify that API token and the eui of my gateway. Then modified the 2nd node with the correct North American url.

Did I miss something?

Figured it out! Your gateway ID is your EUI, mine is not. I made up a name as a gateway ID when I registered it so that confused me.

Thanks for your post!!

1 Like

Thanks Nick, I see this, so is the full URL https://au1.cloud.thethings.network/api/v3/gs/gateways/
image