Browse Source

shuffle around logging

master
Tobias Brunner 9 months ago
parent
commit
901bc5a798
1 changed files with 10 additions and 7 deletions
  1. +10
    -7
      lgt92.py

+ 10
- 7
lgt92.py View File

@ -64,7 +64,11 @@ def on_message_ttn(client, userdata, msg):
batpercent = round((data["payload_fields"]["BatV"] - 3) * 100)
if data["payload_fields"]["ALARM_status"]:
logging.info("ALARM!")
logging.info("Red button pushed!")
logging.info("Motion detection: %s", data["payload_fields"]["MD"])
logging.info("LED status for position: %s", data["payload_fields"]["LON"])
logging.info("Firmware version: %s", data["payload_fields"]["FW"])
got_fix = False
if data["payload_fields"]["Latitude"] == 0:
@ -73,6 +77,10 @@ def on_message_ttn(client, userdata, msg):
data["payload_fields"]["Latitude"] = 0.0
data["payload_fields"]["Longitude"] = 0.0
else:
logging.info("GPS data (Latitude) present: lat %s, lon %s",
data["payload_fields"]["Latitude"],
data["payload_fields"]["Longitude"]
)
got_fix = True
# transform received data into OwnTracks format
ot_data = json.dumps({
@ -87,14 +95,9 @@ def on_message_ttn(client, userdata, msg):
})
# publish to owntracks
logging.info("publishing data to owntracks via mqtt %s", OT_TOPIC)
logging.info("publishing data to owntracks via mqtt to topic %s", OT_TOPIC)
client_ot.publish(OT_TOPIC, payload=ot_data, retain=True, qos=1)
logging.info("Motion detection: %s", data["payload_fields"]["MD"])
logging.info("LED status for position: %s", data["payload_fields"]["LON"])
logging.info("Firmware version: %s", data["payload_fields"]["FW"])
logging.info("ALARM_status: %s", data["payload_fields"]["ALARM_status"])
# write to influxdb
logging.info("writing data to influxdb")
influxdb.write_points(


Loading…
Cancel
Save