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
| Name | Type | Description |
|---|---|---|
| event | str | The solar event that triggers the task (e.g., 'sunrise', 'sunset'). |
| lat | `int | float` |
| lon | `int | float` |
| **kwargs | Any | Additional keyword arguments passed to the BaseSchedule parent class. |
Signature
def solar(
event: str,
lat: float,
lon: float
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| event | str | The specific solar event (e.g., 'sunrise', 'sunset') that triggers the task. |
| lat | float | The latitude of the observer, constrained between -90 and 90. |
| lon | float | The 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
| Name | Type | Description |
|---|---|---|
| last_run_at | datetime | The timestamp of the last successful execution used to calculate the next occurrence. |
Returns
| Type | Description |
|---|---|
timedelta | When 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
| Name | Type | Description |
|---|---|---|
| last_run_at | datetime | The timestamp of the last execution used to determine if the solar event has passed. |
Returns
| Type | Description |
|---|---|
tuple | A 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. |