Failing to write a LoRaWAN gweui into a variable

Hi,

I'm working on a small status monitoring solution for LoRaWAN gateways using metadata of device messages coming in via MQTT.

I'm using https://groups.google.com/g/node-red/c/bahx8U3oBdI?pli=1 as a basis which works fine for me when I use part of the msg.topic string and put it into a variable like Lennart Hennig:

var parts = msg.topic.split ("/");

generating a payload like

be010004: "online"

where be010004 is the split part of the topic.

But what I need is part of the msg.payload like:

gweui: "FCAAAAAAAAAAAAAA"
status: "online"

being modified to a new payload

FCAAAAAAAAAAAAAA: "online"

When I try to enter the gweui into a variable like

var parts = msg.payload.gweui ;

it fails ... as you already might have guessed I'm not really fit in JS and I think I got (again) somewhat lost in JSON object <-> string stuff, but all my attempts to use a JSON converter in Node-RED failed to insufficient know how ...

Any hint welcome !

Matthias

... well, could solve it with the help of a friend :wink: ...

Obviously I tried to access an element of an array which was no array ... well, lessons learned.

I'm now creating the status directly

deviceStatus[msg.payload.gweui] = (msg.payload.status == "true") ? "online" : "offline";

... sorry for the noise !

Matthias

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.