From e51dfe453e317f47076ba78855e11a7a934c6717 Mon Sep 17 00:00:00 2001 From: Geoff Whittington Date: Sat, 5 Aug 2023 18:28:04 -0400 Subject: [PATCH 1/2] Fix plugin issues with later firmware --- plugins/health_plugin.py | 6 ++++-- plugins/nodes_plugin.py | 6 +++++- plugins/telemetry_plugin.py | 12 +++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/plugins/health_plugin.py b/plugins/health_plugin.py index 9d4e9d6..7608440 100644 --- a/plugins/health_plugin.py +++ b/plugins/health_plugin.py @@ -20,8 +20,10 @@ def generate_response(self): for node, info in meshtastic_client.nodes.items(): if "deviceMetrics" in info: - battery_levels.append(info["deviceMetrics"]["batteryLevel"]) - air_util_tx.append(info["deviceMetrics"]["airUtilTx"]) + if "batteryLevel" in info["deviceMetrics"]: + battery_levels.append(info["deviceMetrics"]["batteryLevel"]) + if "airUtilTx" in info["deviceMetrics"]: + air_util_tx.append(info["deviceMetrics"]["airUtilTx"]) if "snr" in info: snr.append(info["snr"]) diff --git a/plugins/nodes_plugin.py b/plugins/nodes_plugin.py index 97f9fef..3bd48ee 100644 --- a/plugins/nodes_plugin.py +++ b/plugins/nodes_plugin.py @@ -55,6 +55,10 @@ def generate_response(self): else: snr = "" + last_heard = None + if "lastHeard" in info: + last_header = get_relative_time(info["lastHeard"]) + voltage = "?V" battery = "?%" if "deviceMetrics" in info: @@ -63,7 +67,7 @@ def generate_response(self): if "batteryLevel" in info["deviceMetrics"]: battery = f"{info['deviceMetrics']['batteryLevel']}%" - response += f"{info['user']['shortName']} {info['user']['longName']} / {info['user']['hwModel']} / {battery} {voltage} / {snr} / {get_relative_time(info['lastHeard'])}\n" + response += f"{info['user']['shortName']} {info['user']['longName']} / {info['user']['hwModel']} / {battery} {voltage} / {snr} / {last_heard}\n" return response diff --git a/plugins/telemetry_plugin.py b/plugins/telemetry_plugin.py index e451917..9cf1f27 100644 --- a/plugins/telemetry_plugin.py +++ b/plugins/telemetry_plugin.py @@ -51,9 +51,15 @@ async def handle_meshtastic_message( telemetry_data.append( { "time": packet_data["time"], - "batteryLevel": packet_data["deviceMetrics"]["batteryLevel"], - "voltage": packet_data["deviceMetrics"]["voltage"], - "airUtilTx": packet_data["deviceMetrics"]["airUtilTx"], + "batteryLevel": packet_data["deviceMetrics"]["batteryLevel"] + if "batteryLevel" in packet_data["deviceMetrics"] + else 0, + "voltage": packet_data["deviceMetrics"]["voltage"] + if "voltage" in packet_data["deviceMetrics"] + else 0, + "airUtilTx": packet_data["deviceMetrics"]["airUtilTx"] + if "airUtilTx" in packet_data["deviceMetrics"] + else 0, } ) self.set_node_data(meshtastic_id=packet["fromId"], node_data=telemetry_data) From f7e952458b3fada048a5baa502eea391a98ff9ea Mon Sep 17 00:00:00 2001 From: Geoff Whittington Date: Sat, 5 Aug 2023 19:01:25 -0400 Subject: [PATCH 2/2] fix map --- plugins/map_plugin.py | 1 - requirements.txt | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/map_plugin.py b/plugins/map_plugin.py index c65cf07..c2a635f 100644 --- a/plugins/map_plugin.py +++ b/plugins/map_plugin.py @@ -17,7 +17,6 @@ def __init__(self, latlng: s2sphere.LatLng, text: str, fontSize: int = 12) -> No self._margin = 4 self._arrow = 16 self._font_size = fontSize - print(self._font_size) def latlng(self) -> s2sphere.LatLng: return self._latlng diff --git a/requirements.txt b/requirements.txt index ed9c2f6..2647d53 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -meshtastic==2.1.8 +Pillow==9.5.0 +meshtastic==2.1.11 py-staticmaps==0.4.0 matrix-nio==0.20.2 matplotlib==3.7.1