# Accessing DEV\_EUI value from TTN message

**URL:** <https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040>\
**Category:** Application Development\
**Created:** [January 19, 2023, 9:33am UTC](https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040 "2023-01-19T09:33:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ambrogio](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/a/a9a28c/32.png) [@ambrogio](https://www.thethingsnetwork.org/forum/u/ambrogio)\
**Post date:** [January 19, 2023, 9:33am UTC](https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040/1 "2023-01-19T09:33:54Z")

</div>

In my application there are a certain number of data-loggers that acquire environmental data. They are all connected via the TTN network. The message payload contains, among other things, the serial number of the end node ( **4 bytes!!** ) which is derived from its MAC address. The same MAC address is also used to compose the DEV\_EUI that the node uses to join the TTN network. Currently I have written a JavaScript _payload formatter_ that unpacks the data contained in the payload and prepares them to be sent to my online database via a _webhook_.  
Is there a programmatic method that allows me to extract the DEV\_EUI from each message? This way I could reduce the size of each message from 13 to 9 bytes. The _payload formatter_ doesn’t seem to be the solution since the payload doesn’t contain this information.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [January 19, 2023, 10:06am UTC](https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040/2 "2023-01-19T10:06:28Z")

</div>

> [@ambrogio](#):
>
> Is there a programmatic method that allows me to extract the DEV\_EUI from each message?

Not with the payload formatter.

Yes if you use parse the other JSON that you are sent along with the contents of the PF

---

<div class="post-metadata">

**Author:** ![enicaltd](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/enicaltd/32/41634_2.png) [@enicaltd](https://www.thethingsnetwork.org/forum/u/enicaltd)\
**Post date:** [January 19, 2023, 3:50pm UTC](https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040/3 "2023-01-19T15:50:02Z")

</div>

No it’s nothing to do with me, I literally saw this post just after I sent mine 🙈

---

<div class="post-metadata">

**Author:** ![ambrogio](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/a/a9a28c/32.png) [@ambrogio](https://www.thethingsnetwork.org/forum/u/ambrogio)\
**Post date:** [January 19, 2023, 5:02pm UTC](https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040/4 "2023-01-19T17:02:10Z")

</div>

OK thanks. I will look for a solution to this problem taking into account your suggestion.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [January 19, 2023, 5:55pm UTC](https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040/5 "2023-01-19T17:55:13Z")

</div>

There isn’t much to look in to - you get a whole bunch of JSON which includes the results of the payload formatter. If you can read the PF JSON, then you can read the dev\_eui field that’s included else where!

The start, note all the loverly id’s supplied …

```auto
"end_device_ids": {
      "device_id": "dtt-tt-soil-01",
      "application_ids": {
        "application_id": "descartes-tinythings-testzone"
      },
      "dev_eui": "DE5CA7777E570000",
      "join_eui": "DE5CA7FFFF777E57",
      "dev_addr": "260B0007"
    },
    "correlation_ids": [
      "as:up:01GQ5JE49JHVQZPBRSHMPD9ANW",
      "ns:uplink:01GQ5JE432NTHVY6EDYAJ46MX1",
      "pba:conn:up:01GPZWDA2M502WPEHSN0KS3K94",
      "pba:uplink:01GQ5JE42X9AYYFE7V9G0YGRX3",
      "rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01GQ5JE432DN073RS21GFENYFF",
      "rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01GQ5JE49HM8P526EPYY2VKERB"
    ],
    "received_at": "2023-01-19T17:50:13.297746419Z",

```

The middle with the **decoded\_payload** not to be relied upon because it doesn’t all ways get created depending on server load:

```auto
    "uplink_message": {
      "session_key_id": "AYXFYQVSfW07+0dCaItp/w==",
      "f_port": 189,
      "f_cnt": 547,
      "frm_payload": "ADkJAAKEA3YGCgM8Bdw=",
      "decoded_payload": {
        "Analog1": 644,
        "Analog2": 886,
        "Analog3": 1546,
        "Analog4": 828,
        "BatteryV": 2.57,
        "DS18Temps": [
          13
        ],
        "DS18s": 1,
        "DigitalIO": 0,
        "DigitalIn1": 0,
        "DigitalIn2": 0,
        "DigitalIn3": 0,
        "DigitalOut": 0,
        "MCUtempC": 9,
        "flags": 0,
        "flagsText": ""
      },

```

The rest …

```auto
      "rx_metadata": [
        {
          "gateway_ids": {
            "gateway_id": "packetbroker"
          },
          "packet_broker": {
            "message_id": "01GQ5JE42X9AYYFE7V9G0YGRX3",
            "forwarder_net_id": "000013",
            "forwarder_tenant_id": "ttnv2",
            "forwarder_cluster_id": "ttn-v2-legacy-eu",
            "forwarder_gateway_eui": "DE5CA70000000000",
            "forwarder_gateway_id": "eui-de5ca70000000000",
            "home_network_net_id": "000013",
            "home_network_tenant_id": "ttn",
            "home_network_cluster_id": "eu1.cloud.thethings.network"
          },
          "rssi": -97,
          "channel_rssi": -97,
          "snr": 3,
          "location": {
            "latitude": 53.57029618,
            "longitude": -2.46078611,
            "altitude": 134
          },
          "uplink_token": "=",
          "received_at": "2023-01-19T17:50:13.081599982Z"
        }
      ],
      "settings": {
        "data_rate": {
          "lora": {
            "bandwidth": 125000,
            "spreading_factor": 7,
            "coding_rate": "4/5"
          }
        },
        "frequency": "867500000"
      },
      "received_at": "2023-01-19T17:50:13.090580307Z",
      "consumed_airtime": "0.066816s",
      "network_ids": {
        "net_id": "000013",
        "tenant_id": "ttn",
        "cluster_id": "eu1",
        "cluster_address": "eu1.cloud.thethings.network"
      }
    }
  }

```

---

<div class="post-metadata">

**Author:** ![ambrogio](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/a/a9a28c/32.png) [@ambrogio](https://www.thethingsnetwork.org/forum/u/ambrogio)\
**Post date:** [January 20, 2023, 11:33am UTC](https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040/6 "2023-01-20T11:33:26Z")

</div>

Thank you,  
in my application each uplink event raised by an end-node is connected to a webhook which transmits a request to my database server. The request contains JSON formatted information as you pointed out to me.  
Currently I have chosen to apply the “up.uplink\_message.decoded\_payload” filter, however this filter generates JSON content that does not report the dev\_eui of the device. I see the gateway EUIs but not the end node one. I’ve tried other available filters but I haven’t found one that also includes the dev\_eui.  
I’m probably making some mistake but I don’t understand where I’m wrong.

![immagine](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/4/c/4c70f044bc503d2c4ada152fe8cb920b04d78128.jpeg)

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [January 20, 2023, 12:00pm UTC](https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040/7 "2023-01-20T12:00:15Z")

</div>

Sorry to be blunt, not sorry, but you’ve put a filter on the event data and you’re not getting the fields you need. 😉

Perhaps remove the filter and then put a filter back once you have what you need and debug from there?

However as it’s a JSON path, you can’t have just the `end_device_ids` and `decoded_payload`.

I’d strongly recommend keeping the `f_cnt` as well - always useful for figuring out if a device has restarted.

---

<div class="post-metadata">

**Author:** ![ambrogio](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/a/a9a28c/32.png) [@ambrogio](https://www.thethingsnetwork.org/forum/u/ambrogio)\
**Post date:** [January 20, 2023, 1:29pm UTC](https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040/8 "2023-01-20T13:29:30Z")

</div>

wow! You were right to be blunt, it helped me 😉  
I had the solution under my eyes and I didn’t see it, in fact by removing any filter I got a much bigger JSON file but with much more information, including the much desired **dev\_eui**  
You helped me solve a problem, I also thank you for your patience 😃 👍

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [January 20, 2023, 1:40pm UTC](https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040/9 "2023-01-20T13:40:28Z")

</div>

Second pair of eye balls always helps!

Can you mark **MY** answer as the solution please!

---

<div class="post-metadata">

**Author:** ![system](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/6/2/6250ea44fd2b0d6259489e1a92748df681e1f970.png) [@system](https://www.thethingsnetwork.org/forum/u/system)\
**Post date:** [January 21, 2023, 1:41pm UTC](https://www.thethingsnetwork.org/forum/t/accessing-dev-eui-value-from-ttn-message/61040/10 "2023-01-21T13:41:21Z")

</div>

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