MQTT - How to subscribe a topic with "decoded_payload" only?

Hi,
I would like to ask if it is possible to subscribe to a topic with only sensor data? Specifically I mean - “decoded_payload”:{“pm10_0”:51, “pm1_0”:35, “pm2_5”:44}.
The code I am using looks like this:
import paho.mqtt.subscribe as subscribe

Blockquote
m = subscribe.simple(topics=[‘v3/work@ttn/devices/eui-c79931364f365558/up’], hostname=“eu1.cloud.thethings.network”, port=1883, auth={‘username’: “work@ttn”,‘password’: “NNSXS…”}, msg_count=2)
for a in m:
print(a.topic)
print(a.payload)

DATA:

Blockquote
b’{“end_device_ids”:{“device_id”:“eui-c79931364f365558”,“application_ids”:{“application_id”:“praca”},“dev_eui”:“C79931364F365558”,“join_eui”:“0000000000000000”,“dev_addr”:“260B683D”},“correlation_ids”:[“as:up:01GMF9S51PE99X7MCQ3YQS7R9B”,“gs:conn:01GM6150M8T8VD81XQA43FDVR2”,“gs:up:host:01GM6150MBK29KKM4RE2SE3KFN”,“gs:uplink:01GMF9S4TW66C07M72W5W9X29N”,“ns:uplink:01GMF9S4TWYKM98ZCD89DRJ0CP”,“rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01GMF9S4TW7SDPB7ZFD74NQR4W”,“rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01GMF9S51NNQ1CM2RK39PE16X2”],“received_at”:“2022-12-17T05:44:16.181578208Z”,“uplink_message”:{“session_key_id”:“AYUem5ZIVCm5gYH4dV3+Og==”,“f_port”:10,“frm_payload”:“IwAsADMA”,“decoded_payload”:{“pm10_0”:51,“pm1_0”:35,“pm2_5”:44},“rx_metadata”:[{“gateway_ids”:{“gateway_id”:“netlab-we-pb”,“eui”:“7276FF0039040296”},“time”:“2022-12-17T05:44:15.932712Z”,“timestamp”:1252443108,“rssi”:-122,“channel_rssi”:-122,“snr”:-0.5,“location”:{“latitude”:53.11750286637398,“longitude”:23.149580061435703,“altitude”:163,“source”:“SOURCE_REGISTRY”},“uplink_token”:“ChoKGAoMbmV0bGFiLXdlLXBiEghydv8AOQQClhDkh5vVBBoMCK+u9ZwGEN+rzcsDIKDltNu5yUc=”,“channel_index”:6,“received_at”:“2022-12-17T05:44:14.388142363Z”},{“gateway_ids”:{“gateway_id”:“50313953a3694750”,“eui”:“50313953A3694750”},“time”:“2022-12-17T05:44:24.438966Z”,“timestamp”:2613106564,“rssi”:-105,“channel_rssi”:-105,“snr”:0.75,“location”:{“latitude”:53.13277873712397,“longitude”:23.13817799091339,“altitude”:160,“source”:“SOURCE_REGISTRY”},“uplink_token”:“Ch4KHAoQNTAzMTM5NTNhMzY5NDc1MBIIUDE5U6NpR1AQhK+D3gkaDAivrvWcBhCK04DSAyCgt6fKhrJc”,“channel_index”:1,“received_at”:“2022-12-17T05:44:15.948930954Z”}],“settings”:{“data_rate”:{“lora”:{“bandwidth”:125000,“spreading_factor”:7,“coding_rate”:“4/5”}},“frequency”:“868300000”,“timestamp”:1252443108,“time”:“2022-12-17T05:44:15.932712Z”},“received_at”:“2022-12-17T05:44:15.964816209Z”,“consumed_airtime”:“0.051456s”,“locations”:{“user”:{“latitude”:53.11880755944648,“longitude”:23.134897532509516,“source”:“SOURCE_REGISTRY”}},“network_ids”:{“net_id”:“000013”,“tenant_id”:“ttn”,“cluster_id”:“eu1”,“cluster_address”:“eu1.cloud.thethings.network”}}}’

There is a lot of data in this topic, too much, but I am only interested in the data from my sensor :frowning: Thanks in advance.

Searching the forum will explain all the details as this comes up every few months, but the short answer is that there is no configuration of the payload, that’s it, you’ll just have to pick out the bits you want & ignore the rest.

1 Like