From bef2efcbdfc8de45f32f5260b29ea7ff763dcf6a Mon Sep 17 00:00:00 2001 From: Ace Date: Tue, 27 Aug 2024 15:04:09 +0200 Subject: [PATCH] improve handling when piSugar is off --- inkycal/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/inkycal/main.py b/inkycal/main.py index cef0e11a..62380828 100644 --- a/inkycal/main.py +++ b/inkycal/main.py @@ -163,7 +163,12 @@ def __init__(self, settings_path: str or None = None, render: bool = True, use_p self.pisugar = PiSugar() self.battery_capacity = self.pisugar.get_battery() - logger.info(f"PiSugar battery capacity: {self.battery_capacity}%") + + if not self.battery_capacity: + logger.warning("[PISUGAR] Could not get battery capacity! Is the board off? Setting battery capacity to 0%") + self.battery_capacity = 100 + else: + logger.info(f"PiSugar battery capacity: {self.battery_capacity}%") if self.battery_capacity < 20: logger.warning("Battery capacity is below 20%!")