From a59ea1e901fbea72a8769e7d56effcf61585c412 Mon Sep 17 00:00:00 2001 From: Tomaae <23486452+tomaae@users.noreply.github.com> Date: Thu, 25 Apr 2024 18:24:04 +0200 Subject: [PATCH] Fixed crash when eth is disconnected, ref #102 --- custom_components/truenas/coordinator.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/custom_components/truenas/coordinator.py b/custom_components/truenas/coordinator.py index f3831f2..07f9656 100644 --- a/custom_components/truenas/coordinator.py +++ b/custom_components/truenas/coordinator.py @@ -491,6 +491,9 @@ def get_systemstats(self) -> None: tmp_val = ( tmp_graph[i]["aggregations"]["mean"][tmp_var] or 0.0 + if tmp_var + in tmp_graph[i]["aggregations"]["mean"] + else 0.0 ) self.ds["interface"][tmp_etc][tmp_var] = round( (tmp_val * 0.12207), 2 @@ -498,6 +501,8 @@ def get_systemstats(self) -> None: else: tmp_val = ( tmp_graph[i]["aggregations"]["mean"][e] or 0.0 + if e in tmp_graph[i]["aggregations"]["mean"] + else 0.0 ) self.ds["interface"][tmp_etc][tmp_var] = round( (tmp_val / 1024), 2