this and that

This commit is contained in:
Ace 2024-06-24 02:16:08 +02:00
parent 310fefa1ae
commit 36b5906534

View File

@ -35,7 +35,7 @@ class PiSugar:
logger.error(f"Error executing command: {e}") logger.error(f"Error executing command: {e}")
return None return None
def get_battery(self) -> int or None: def get_battery(self) -> float or None:
"""Get the battery level in percentage. """Get the battery level in percentage.
Returns: Returns:
@ -45,7 +45,7 @@ class PiSugar:
if battery_output: if battery_output:
for line in battery_output.splitlines(): for line in battery_output.splitlines():
if 'battery:' in line: if 'battery:' in line:
return int(line.split(':')[1].strip()) return float(line.split(':')[1].strip())
return None return None
def get_model(self) -> str or None: def get_model(self) -> str or None:
@ -57,12 +57,12 @@ class PiSugar:
return line.split(':')[1].strip() return line.split(':')[1].strip()
return None return None
def get_rtc_time(self) -> str or None: def get_rtc_time(self) -> arrow.arrow or None:
"""Get the RTC time.""" """Get the RTC time."""
result = self._get_output("get rtc_time") result = self._get_output("get rtc_time")
if result: if result:
second_line = result.splitlines()[1] rtc_time = result.split("rtc_time: ")[1].strip()
return second_line.split('rtc_time: ')[1].strip() return arrow.get(rtc_time)
return None return None
def get_rtc_alarm_enabled(self) -> str or None: def get_rtc_alarm_enabled(self) -> str or None:
@ -78,8 +78,7 @@ class PiSugar:
"""Get the RTC alarm time.""" """Get the RTC alarm time."""
result = self._get_output("get rtc_alarm_time") result = self._get_output("get rtc_alarm_time")
if result: if result:
second_line = result.splitlines()[1] alarm_time = result.split('rtc_alarm_time: ')[1].strip()
alarm_time = second_line.split('rtc_alarm_time: ')[1].strip()
return arrow.get(alarm_time) return arrow.get(alarm_time)
return None return None