Skip to content

Latest commit

 

History

History
148 lines (93 loc) · 3.03 KB

weather.md

File metadata and controls

148 lines (93 loc) · 3.03 KB

weather

Weather Sensor and a weather forecast Service implementation.

WeatherSensor Objects

class WeatherSensor(Sensor)

Provide instantaneous weather information as a Sensor.

It uses the OpenWeather API.

read

@Pyro5.api.expose
def read(**kwargs) -> dict

Return the current weather conditions.

The conditions includes the 'temperature', 'wind_speed', 'wind_degree', 'weather_code' and 'humidity' level information.

For more details on the 'weather_code' field, consult https://openweathermap.org/weather-conditions.

WeatherForecastService Objects

class WeatherForecastService()

Provide weather forecast information.

It uses on the National Weather Service (NWS) API.

conditions_at

@Pyro5.api.expose
def conditions_at(target: datetime) -> dict

Return the condition at TARGET time.

The conditions include the 'temperature', 'wind_speed' and 'wind_degree'.

minimum_temperature

@Pyro5.api.expose
def minimum_temperature(hours=24)

Minimum temperature in the next HOURS hours.

maximum_temperature

@Pyro5.api.expose
def maximum_temperature(hours=24)

Maximum temperature in the next HOURS hours.

WeatherProxy Objects

class WeatherProxy(Sensor)

Helper class for weather Sensor and Service.

This class is a wrapper of the weather sensor and service with exception handlers. It provides convenience for services using the weather Sensor and Service by suppressing the burden of locating them and handling the various remote object related errors.

This class also introduces some direct attributes such as 'temperature', 'wind_speed', 'wind_degree', 'weather_code' and 'humidity' providing simpler access to the current weather condition information. These fields can also be retrieved all at once using the 'read' method.

It introduces the 'temperature_at(datetime)', 'wind_speed_at(datetime)' and 'wind_direction_at(datetime)' methods providing a simpler access to targeted weather forecast information. These fields can also be retrieved all at once using the 'conditions_at(datetime)' method.

read

def read(**kwargs) -> dict

Return the instantaneous weather condition.

units

def units(**kwargs) -> dict

Return the instantaneous weather condition.

conditions_at

def conditions_at(date: datetime) -> dict

Return the forecast weather condition at 'date'.

main

def main()

Register and run the weather Sensor and weather forecast Service.