BCApis.Weather (bc_apis v0.1.0)

Weather service for integrating with Open-Meteo API.

Provides functions to fetch current weather data and correlate it with greenhouse environmental conditions.

Open-Meteo is a free, open-source weather API that doesn't require an API key.

Summary

Functions

Fetches current weather data for a given location.

Fetches UV index data for a given location.

Converts outdoor weather conditions to estimated greenhouse conditions.

Functions

get_current_weather(lat, lon, api_key)

@spec get_current_weather(float(), float(), String.t()) ::
  {:ok, map()} | {:error, term()}

Fetches current weather data for a given location.

Parameters

  • lat: Latitude (float)
  • lon: Longitude (float)
  • api_key: Not used (Open-Meteo is free and doesn't require API key)

Returns

  • {:ok, weather_data} on success
  • {:error, reason} on failure

get_uv_index(lat, lon, api_key)

@spec get_uv_index(float(), float(), String.t()) :: {:ok, map()} | {:error, term()}

Fetches UV index data for a given location.

Parameters

  • lat: Latitude (float)
  • lon: Longitude (float)
  • api_key: Not used (Open-Meteo is free and doesn't require API key)

Returns

  • {:ok, uv_data} on success
  • {:error, reason} on failure

weather_to_greenhouse_conditions(weather_data)

@spec weather_to_greenhouse_conditions(map()) :: map()

Converts outdoor weather conditions to estimated greenhouse conditions.

Greenhouses typically have:

  • Higher temperature (due to greenhouse effect)
  • Higher humidity (controlled environment)
  • Reduced light (filtered through glass/plastic)