Skip to content

Commit

Permalink
Fix nodes issue when metrics are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
berticus2016 committed Jun 10, 2023
1 parent ed9f3a7 commit ffe969f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions plugins/nodes_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ def generate_response(self):
snr = f"{info['snr']} dB"
else:
snr = ""
if "voltage" in info["deviceMetrics"]:
voltage = f"{info['deviceMetrics']['voltage']}V"
else:
voltage = "?V"
if "batteryLevel" in info["deviceMetrics"]:
battery = f"{info['deviceMetrics']['batteryLevel']}%"
else:
battery = "?%"

voltage = "?V"
battery = "?%"
if "deviceMetrics" in info:
if "voltage" in info["deviceMetrics"]:
voltage = f"{info['deviceMetrics']['voltage']}V"
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"

return response
Expand Down

0 comments on commit ffe969f

Please sign in to comment.