diff --git a/inkycal/main.py b/inkycal/main.py index 150e865..b485ac4 100644 --- a/inkycal/main.py +++ b/inkycal/main.py @@ -81,10 +81,10 @@ class Inkycal: if self.render: # Init Display class with model in settings file # from inkycal.display import Display - self.Display = Display(settings["model"]) + self.Display = Display(self.settings["model"]) # check if colours can be rendered - self.supports_colour = True if 'colour' in settings['model'] else False + self.supports_colour = True if 'colour' in self.settings['model'] else False # get calibration hours self._calibration_hours = self.settings['calibration_hours'] diff --git a/inkycal/utils/pisugar.py b/inkycal/utils/pisugar.py index a1b1463..eb40da9 100644 --- a/inkycal/utils/pisugar.py +++ b/inkycal/utils/pisugar.py @@ -4,6 +4,7 @@ import logging import subprocess from inkycal.settings import Settings +import arrow settings = Settings() @@ -73,12 +74,13 @@ class PiSugar: return True if output == "true" else False return None - def get_rtc_alarm_time(self) -> str or None: + def get_rtc_alarm_time(self) -> arrow.arrow or None: """Get the RTC alarm time.""" result = self._get_output("get rtc_alarm_time") if result: second_line = result.splitlines()[1] - return second_line.split('rtc_alarm_time: ')[1].strip() + alarm_time = second_line.split('rtc_alarm_time: ')[1].strip() + return arrow.get(alarm_time) return None def get_alarm_repeat(self) -> dict or None: @@ -124,4 +126,22 @@ class PiSugar: return True return False + def rtc_alarm_set(self, time: arrow.arrow) -> bool: + """Set the RTC alarm time. + + Args: + time (arrow.arrow): The alarm time in ISO 8601 format. + + Returns: + bool: True if the alarm was set successfully, False otherwise. + """ + iso_format = time.isoformat() + result = self._get_output(f"rtc_alarm_set {iso_format}") + if result: + second_line = result.splitlines()[1] + status = second_line.split('rtc_alarm_set: ')[1].strip() + if status == "done": + return True + return False +