Skip to main content

solar

Solar event. A solar event can be used as the run_every value of a periodic task entry to schedule based on certain solar events.

Constructor

Signature

def solar(
event: str,
lat: int | float,
lon: int | float,
**kwargs: Any
) - > None

Parameters

NameTypeDescription
eventstrThe solar event that triggers the task (e.g., 'sunrise', 'sunset').
lat`intfloat`
lon`intfloat`
**kwargsAnyAdditional keyword arguments passed to the BaseSchedule parent class.

Signature

def solar(
event: str,
lat: float,
lon: float
) - > null

Parameters

NameTypeDescription
eventstrThe specific solar event (e.g., 'sunrise', 'sunset') that triggers the task.
latfloatThe latitude of the observer, constrained between -90 and 90.
lonfloatThe longitude of the observer, constrained between -180 and 180.

Methods


remaining_estimate()

@classmethod
def remaining_estimate(
last_run_at: datetime
) - > timedelta

Return estimate of next time to run.

Parameters

NameTypeDescription
last_run_atdatetimeThe timestamp of the last successful execution used to calculate the next occurrence.

Returns

TypeDescription
timedeltaWhen the periodic task should run next, or if it shouldn't run today (e.g., the sun does not rise today), returns the time when the next check should take place.

is_due()

@classmethod
def is_due(
last_run_at: datetime
) - > tuple

Return tuple of (is_due, next_time_to_run).

Parameters

NameTypeDescription
last_run_atdatetimeThe timestamp of the last execution used to determine if the solar event has passed.

Returns

TypeDescription
tupleA tuple where the first element is a boolean indicating if the task is due, and the second is the delay until the next run in seconds.