From 36b5906534b4e7e209518814a9379933ee0061a2 Mon Sep 17 00:00:00 2001 From: Ace Date: Mon, 24 Jun 2024 02:16:08 +0200 Subject: [PATCH] this and that --- inkycal/utils/pisugar.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/inkycal/utils/pisugar.py b/inkycal/utils/pisugar.py index eb40da9..851bebd 100644 --- a/inkycal/utils/pisugar.py +++ b/inkycal/utils/pisugar.py @@ -35,7 +35,7 @@ class PiSugar: logger.error(f"Error executing command: {e}") return None - def get_battery(self) -> int or None: + def get_battery(self) -> float or None: """Get the battery level in percentage. Returns: @@ -45,7 +45,7 @@ class PiSugar: if battery_output: for line in battery_output.splitlines(): if 'battery:' in line: - return int(line.split(':')[1].strip()) + return float(line.split(':')[1].strip()) return None def get_model(self) -> str or None: @@ -57,12 +57,12 @@ class PiSugar: return line.split(':')[1].strip() return None - def get_rtc_time(self) -> str or None: + def get_rtc_time(self) -> arrow.arrow or None: """Get the RTC time.""" result = self._get_output("get rtc_time") if result: - second_line = result.splitlines()[1] - return second_line.split('rtc_time: ')[1].strip() + rtc_time = result.split("rtc_time: ")[1].strip() + return arrow.get(rtc_time) return None def get_rtc_alarm_enabled(self) -> str or None: @@ -78,8 +78,7 @@ class PiSugar: """Get the RTC alarm time.""" result = self._get_output("get rtc_alarm_time") if result: - second_line = result.splitlines()[1] - alarm_time = second_line.split('rtc_alarm_time: ')[1].strip() + alarm_time = result.split('rtc_alarm_time: ')[1].strip() return arrow.get(alarm_time) return None