From 659370e1eb4f4e7cf65774e31775bd7597b0c115 Mon Sep 17 00:00:00 2001 From: Jack Kingsman Date: Sun, 29 Mar 2026 18:02:59 -0700 Subject: [PATCH] Don't cast SNR/RSSI to string. Closes #121. --- app/fanout/community_mqtt.py | 7 ++++--- tests/test_community_mqtt.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/fanout/community_mqtt.py b/app/fanout/community_mqtt.py index 632572d..cd9eef1 100644 --- a/app/fanout/community_mqtt.py +++ b/app/fanout/community_mqtt.py @@ -175,11 +175,12 @@ def _format_raw_packet(data: dict[str, Any], device_name: str, public_key_hex: s current_time = datetime.now() ts_str = current_time.isoformat() - # SNR/RSSI are always strings in reference output. + # Keep numeric telemetry numeric so downstream analyzers can ingest it. + # Preserve the existing "Unknown" fallback for missing values. snr_val = data.get("snr") rssi_val = data.get("rssi") - snr = str(snr_val) if snr_val is not None else "Unknown" - rssi = str(rssi_val) if rssi_val is not None else "Unknown" + snr: float | str = float(snr_val) if snr_val is not None else "Unknown" + rssi: int | str = int(rssi_val) if rssi_val is not None else "Unknown" packet_hash = _calculate_packet_hash(raw_bytes) diff --git a/tests/test_community_mqtt.py b/tests/test_community_mqtt.py index 462860d..a8b5182 100644 --- a/tests/test_community_mqtt.py +++ b/tests/test_community_mqtt.py @@ -210,8 +210,8 @@ class TestPacketFormatConversion: assert result["origin"] == "TestNode" assert result["origin_id"] == "AABBCCDD" * 8 assert result["raw"] == "0A1B2C3D" - assert result["SNR"] == "5.5" - assert result["RSSI"] == "-90" + assert result["SNR"] == 5.5 + assert result["RSSI"] == -90 assert result["type"] == "PACKET" assert result["direction"] == "rx" assert result["len"] == "4"