pyowm.alertapi30 package¶
Submodules¶
pyowm.alertapi30.alert_manager module¶
pyowm.alertapi30.alert module¶
-
class
pyowm.alertapi30.alert.
Alert
(id, trigger_id, met_conditions, coordinates, last_update=None)[source]¶ Bases:
object
Represents the situation happening when any of the conditions bound to a Trigger is met. Whenever this happens, an Alert object is created (or updated) and is bound to its parent Trigger. The trigger can then be polled to check what alerts have been fired on it. :param id: unique alert identifier :type name: str :param trigger_id: link back to parent Trigger :type trigger_id: str :param met_conditions: list of dict, each one referring to a Condition obj bound to the parent Trigger and reporting the actual measured values that made this Alert fire :type met_conditions: list of dict :param coordinates: dict representing the geocoordinates where the Condition triggering the Alert was met :type coordinates: dict :param last_update: epoch of the last time when this Alert has been fired :type last_update: int
-
class
pyowm.alertapi30.alert.
AlertChannel
(name)[source]¶ Bases:
object
Base class representing a channel through which one can acknowledge that a weather alert has been issued. Examples: OWM API polling, push notifications, email notifications, etc. This feature is yet to be implemented by the OWM API. :param name: name of the channel :type name: str :returns: an AlertChannel instance
pyowm.alertapi30.condition module¶
-
class
pyowm.alertapi30.condition.
Condition
(weather_param, operator, amount, id=None)[source]¶ Bases:
object
Object representing a condition to be checked on a specific weather parameter. A condition is given when comparing the weather parameter against a numerical value with respect to an operator. Allowed weather params and operators are specified by the pyowm.utils.alertapi30.WeatherParametersEnum and pyowm.utils.alertapi30.OperatorsEnum enumerator classes. :param weather_param: the weather variable to be checked (eg. TEMPERATURE, CLOUDS, …) :type weather_param: str :param operator: the comparison operator to be applied to the weather variable (eg. GREATER_THAN, EQUAL, …) :type operator: str :param amount: comparison value :type amount: int or float :param id: optional unique ID for this Condition instance :type id: str :returns: a Condition instance :raises: AssertionError when either the weather param has wrong type or the operator has wrong type or the amount has wrong type
pyowm.alertapi30.enums module¶
-
class
pyowm.alertapi30.enums.
AlertChannelsEnum
[source]¶ Bases:
object
Allowed alert channels
-
OWM_API_POLLING
= <pyowm.alertapi30.alert.AlertChannel object>¶
-
-
class
pyowm.alertapi30.enums.
OperatorsEnum
[source]¶ Bases:
object
Allowed comparison operators for condition checking upon weather parameters
-
EQUAL
= '$eq'¶
-
GREATER_THAN
= '$gt'¶
-
GREATER_THAN_EQUAL
= '$gte'¶
-
LESS_THAN
= '$lt'¶
-
LESS_THAN_EQUAL
= '$lte'¶
-
NOT_EQUAL
= '$ne'¶
-
pyowm.alertapi30.trigger module¶
-
class
pyowm.alertapi30.trigger.
Trigger
(start_after_millis, end_after_millis, conditions, area, alerts=None, alert_channels=None, id=None)[source]¶ Bases:
object
Object representing a the check if a set of weather conditions are met on a given geographical area: each condition is a rule on the value of a given weather parameter (eg. humidity, temperature, etc). Whenever a condition from a Trigger is met, the OWM API crates an alert and binds it to the the Trigger. A Trigger is the local proxy for the corresponding entry on the OWM API, therefore it can get ouf of sync as time goes by and conditions are met: it’s up to you to “refresh” the local trigger by using a pyowm.utils.alertapi30.AlertManager instance. :param start_after_millis: how many milliseconds after the trigger creation the trigger begins to be checked :type start_after_millis: int :param end_after_millis: how many milliseconds after the trigger creation the trigger ends to be checked :type end_after_millis: int :param alerts: the Alert objects representing the alerts that have been fired for this Trigger so far. Defaults to None :type alerts: list of pyowm.utils.alertapi30.Alert instances :param conditions: the Condition objects representing the set of checks to be done on weather variables :type conditions: list of pyowm.utils.alertapi30.Condition instances :param area: the geographic are over which conditions are checked: it can be composed by multiple geoJSON types :type area: list of geoJSON types :param alert_channels: the alert channels through which alerts originating from this Trigger can be consumed. Defaults to OWM API polling :type alert_channels: list of pyowm.utils.alertapi30.AlertChannel instances :param id: optional unique ID for this Trigger instance :type id: str :returns: a Trigger instance :raises: ValueError when start or end epochs are None or when end precedes start or when conditions or area are empty collections
-
get_alert
(alert_id)[source]¶ Returns the Alert of this Trigger having the specified ID :param alert_id: str, the ID of the alert :return: Alert instance
-
get_alerts_on
(weather_param)[source]¶ Returns all the Alert objects of this Trigger that refer to the specified weather parameter (eg. ‘temp’, ‘pressure’, etc.). The allowed weather params are the ones enumerated by class pyowm.alertapi30.enums.WeatherParametersEnum :param weather_param: str, values in pyowm.alertapi30.enums.WeatherParametersEnum :return: list of Alert instances
-
get_alerts_since
(timestamp)[source]¶ Returns all the Alert objects of this Trigger that were fired since the specified timestamp. :param timestamp: time object representing the point in time since when alerts have to be fetched :type timestamp: int,
datetime.datetime
or ISO8601-formatted string :return: list of Alert instances
-