From 7cc1b36697b19a26902aaac28a89d16e9ccb31e4 Mon Sep 17 00:00:00 2001 From: Christian Elsen Date: Sun, 2 Mar 2025 17:11:13 -0800 Subject: [PATCH] Use device's last check-in time for stale time calculation --- inrcot/functions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inrcot/functions.py b/inrcot/functions.py index 57615a6..6079be8 100644 --- a/inrcot/functions.py +++ b/inrcot/functions.py @@ -119,11 +119,11 @@ def inreach_to_cot_xml( time = when - # We want to use localtime + stale instead of lastUpdate time + stale - # This means a device could go offline and we might not know it? + # Use the devices last update time to calculate the stale time + # If the device goes offline it will be removed _cot_stale = feed_conf.get("cot_stale", inrcot.DEFAULT_COT_STALE) cot_stale = ( - datetime.datetime.now(datetime.timezone.utc) + datetime.datetime.strptime(time, "%Y-%m-%dT%H:%M:%SZ") + datetime.timedelta(seconds=int(_cot_stale)) ).strftime(pytak.ISO_8601_UTC)