Skip to content

Commit

Permalink
Fix plugin issues with later firmware (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffwhittington committed Aug 5, 2023
1 parent ffe969f commit 734020b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
6 changes: 4 additions & 2 deletions plugins/health_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down
6 changes: 5 additions & 1 deletion plugins/nodes_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
12 changes: 9 additions & 3 deletions plugins/telemetry_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 734020b

Please sign in to comment.