new datastructure
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
13cff5e9f3
commit
43969fa842
13
rhf1s001.py
13
rhf1s001.py
|
@ -28,8 +28,7 @@ def on_log(client, userdata, level, buf):
|
||||||
# The callback for when a PUBLISH message is received from the server.
|
# The callback for when a PUBLISH message is received from the server.
|
||||||
def on_message_ttn(client, userdata, msg):
|
def on_message_ttn(client, userdata, msg):
|
||||||
data = json.loads(msg.payload)
|
data = json.loads(msg.payload)
|
||||||
logging.info("message from ttn received for %s - #%s", data["dev_id"], data["counter"])
|
logging.info("new data received via gw %s", data["uplink_message"]["rx_metadata"][0]["gateway_ids"]["gateway_id"])
|
||||||
logging.info("received via gw %s", data["metadata"]["gateways"][0]["gtw_id"])
|
|
||||||
|
|
||||||
# write to influxdb
|
# write to influxdb
|
||||||
logging.info("writing data to influxdb")
|
logging.info("writing data to influxdb")
|
||||||
|
@ -41,11 +40,11 @@ def on_message_ttn(client, userdata, msg):
|
||||||
"device": "rhf1s001",
|
"device": "rhf1s001",
|
||||||
},
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"battery": data["payload_fields"]["battery"],
|
"battery": data["uplink_message"]["decoded_payload"]["battery"],
|
||||||
"hum": data["payload_fields"]["hum"],
|
"hum": data["uplink_message"]["decoded_payload"]["hum"],
|
||||||
"temp": data["payload_fields"]["temp"],
|
"temp": data["uplink_message"]["decoded_payload"]["temp"],
|
||||||
"counter": data["counter"],
|
"counter": data["uplink_message"]["f_cnt"],
|
||||||
"rssi": data["metadata"]["gateways"][0]["rssi"],
|
"rssi": data["uplink_message"]["rx_metadata"][0]["rssi"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue