small improvements
This commit is contained in:
parent
17c13e6d8e
commit
310fefa1ae
@ -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']
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user