# Failing to write a LoRaWAN gweui into a variable

**URL:** https://discourse.nodered.org/t/failing-to-write-a-lorawan-gweui-into-a-variable/41939
**Category:** General
**Created:** [3 March 2021 10:21 UTC](https://discourse.nodered.org/t/failing-to-write-a-lorawan-gweui-into-a-variable/41939 "2021-03-03T10:21:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![manankanchu](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@manankanchu](https://discourse.nodered.org/u/manankanchu)
#### Post date: [3 March 2021 10:21 UTC](https://discourse.nodered.org/t/failing-to-write-a-lorawan-gweui-into-a-variable/41939/1 "2021-03-03T10:21:21Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![manankanchu](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@manankanchu](https://discourse.nodered.org/u/manankanchu)
#### Post date: [3 March 2021 13:48 UTC](https://discourse.nodered.org/t/failing-to-write-a-lorawan-gweui-into-a-variable/41939/2 "2021-03-03T13:48:16Z")

</div>

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

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [17 March 2021 13:48 UTC](https://discourse.nodered.org/t/failing-to-write-a-lorawan-gweui-into-a-variable/41939/3 "2021-03-17T13:48:59Z")

</div>

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