send to traccar
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
df89854803
commit
0115bab9dd
16
lgt92.py
16
lgt92.py
|
@ -19,8 +19,9 @@ DST_INFLUX_HOST = os.getenv("DST_INFLUX_HOST")
|
|||
DST_INFLUX_USER = os.getenv("DST_INFLUX_USER")
|
||||
DST_INFLUX_PASS = os.getenv("DST_INFLUX_PASS")
|
||||
DST_INFLUX_DB = os.getenv("DST_INFLUX_DB")
|
||||
DST_TRACCAR_URL = os.getenv("DST_TRACCAR_URL")
|
||||
HC_PING_URL = os.getenv("HC_PING_URL")
|
||||
VERSION = "v3.0"
|
||||
VERSION = "v3.1"
|
||||
|
||||
OT_TOPIC = "owntracks/tobru/dragino"
|
||||
OT_TID = "dragino"
|
||||
|
@ -81,8 +82,14 @@ def on_message_ttn(client, userdata, msg):
|
|||
roll = data["uplink_message"]["decoded_payload"]["Roll"]
|
||||
latitude = data["uplink_message"]["decoded_payload"]["Latitude"]
|
||||
longitude = data["uplink_message"]["decoded_payload"]["Longitude"]
|
||||
altitude = data["uplink_message"]["decoded_payload"]["Altitude"]
|
||||
if data["uplink_message"]["decoded_payload"]["HDOP"]:
|
||||
hdop = data["uplink_message"]["decoded_payload"]["HDOP"]
|
||||
else:
|
||||
hdop = 0
|
||||
rssi = data["uplink_message"]["rx_metadata"][0]["rssi"]
|
||||
airtime = data["uplink_message"]["consumed_airtime"][:-1]
|
||||
timestamp = int(datetime.timestamp(datetime.now()))
|
||||
|
||||
# max is 4 volts, 3 volts is considered empty
|
||||
batpercent = round((bat_v - 3) * 100)
|
||||
|
@ -118,7 +125,7 @@ def on_message_ttn(client, userdata, msg):
|
|||
"batt": batpercent,
|
||||
"t": "p",
|
||||
"tid": OT_TID,
|
||||
"tst": int(datetime.timestamp(datetime.now())),
|
||||
"tst": timestamp,
|
||||
"conn": "m",
|
||||
}
|
||||
)
|
||||
|
@ -127,6 +134,11 @@ def on_message_ttn(client, userdata, msg):
|
|||
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)
|
||||
|
||||
# send to traccar
|
||||
logging.info("publishing data to traccar")
|
||||
traccar_url = f"{DST_TRACCAR_URL}/?id={OT_TID}&lat={latitude}&lon={longitude}×tamp={timestamp}&hdop={hdop}&altitude={altitude}&speed=0"
|
||||
requests.get(traccar_url)
|
||||
|
||||
# write to influxdb
|
||||
logging.info("writing data to influxdb")
|
||||
influxdb_points = [
|
||||
|
|
Loading…
Reference in New Issue