Browse Source

adapt for new fw version

master
Tobias Brunner 9 months ago
parent
commit
27e65c29ec
1 changed files with 8 additions and 7 deletions
  1. +8
    -7
      lgt92.py

+ 8
- 7
lgt92.py View File

@ -64,10 +64,15 @@ def on_message_ttn(client, userdata, msg):
batpercent = round((data["payload_fields"]["BatV"] - 3) * 100)
if data["payload_fields"]["ALARM_status"]:
print("ALARM button pressed")
logging.info("ALARM!")
got_fix = False
if "Latitude" in data["payload_fields"]:
if data["payload_fields"]["Latitude"] == 0:
logging.info("no GPS data (Latitude) present")
# set GPS data to 0 for InfluxDB
data["payload_fields"]["Latitude"] = 0.0
data["payload_fields"]["Longitude"] = 0.0
else:
got_fix = True
# transform received data into OwnTracks format
ot_data = json.dumps({
@ -84,15 +89,11 @@ def on_message_ttn(client, userdata, msg):
# publish to owntracks
logging.info("publishing data to owntracks via mqtt %s", OT_TOPIC)
client_ot.publish(OT_TOPIC, payload=ot_data, retain=True, qos=1)
else:
logging.info("no GPS data (latitude) present")
# set GPS data to 0 for InfluxDB
data["payload_fields"]["Latitude"] = 0.0
data["payload_fields"]["Longitude"] = 0.0
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")


Loading…
Cancel
Save