Module i3status_rs::blocks::weather

source ·
Expand description

Current weather

This block displays local weather and temperature information. In order to use this block, you will need access to a supported weather API service. At the time of writing, OpenWeatherMap and met.no are supported.

Configuring this block requires configuring a weather service, which may require API keys and other parameters.

If using the autolocate feature, set the autolocate update interval such that you do not exceed ipapi.co’s free daily limit of 1000 hits. Or use autolocate_interval = "once" to only run on initialization.

§Configuration

KeyValuesDefault
serviceThe configuration of a weather service (see below).Required
formatA string to customise the output of this block. See below for available placeholders. Text may need to be escaped, refer to Escaping Text." $icon $weather $temp "
format_altIf set, block will switch between format and format_alt on every clickNone
intervalUpdate interval, in seconds.600
autolocateGets your location using the ipapi.co IP location service (no API key required). If the API call fails then the block will fallback to service specific location config.false
autolocate_intervalUpdate interval for autolocate in seconds or “once”interval

§OpenWeatherMap Options

To use the service you will need a (free) API key.

KeyValuesRequiredDefault
nameopenweathermap.YesNone
api_keyYour OpenWeatherMap API key.YesNone
coordinatesGPS latitude longitude coordinates as a tuple, example: ["39.2362","9.3317"]Yes*None
city_idOpenWeatherMap’s ID for the city. (Deprecated)Yes*None
placeOpenWeatherMap ‘By {city name},{state code},{country code}’ search query. See here. Consumes an additional API callYes*None
zipOpenWeatherMap ‘By {zip code},{country code}’ search query. See here. Consumes an additional API callYes*None
unitsEither "metric" or "imperial".No"metric"
langLanguage code. See here. Currently only affects weather_verbose key.No"en"
forecast_hoursHow many hours should be forecast (must be increments of 3 hours, max 120 hours)No12

One of coordinates, city_id, place, or zip is required. If more than one are supplied, coordinates takes precedence over city_id which takes precedence over place which takes precedence over zip.

The options api_key, city_id, place, zip, can be omitted from configuration, in which case they must be provided in the environment variables OPENWEATHERMAP_API_KEY, OPENWEATHERMAP_CITY_ID, OPENWEATHERMAP_PLACE, OPENWEATHERMAP_ZIP.

Forecasts are only fetched if forecast_hours > 0 and the format has keys related to forecast.

§met.no Options

KeyValuesRequiredDefault
namemetno.YesNone
coordinatesGPS latitude longitude coordinates as a tuple, example: ["39.2362","9.3317"]Required if autolocate = falseNone
langLanguage code: en, nn or nbNoen
altitudeMeters above sea level of the groundNoApproximated by server
forecast_hoursHow many hours should be forecastNo12

Met.no does not support location name, but if autolocate is enabled then autolocate’s city value is used.

§Available Format Keys

KeyValueTypeUnit
locationLocation name (exact format depends on the service)Text-
icon{,_ffin}Icon representing the weatherIcon-
weather{,_ffin}Textual brief description of the weather, e.g. “Raining”Text-
weather_verbose{,_ffin}Textual verbose description of the weather, e.g. “overcast clouds”Text-
temp{,_{favg,fmin,fmax,ffin}}TemperatureNumberdegrees
apparent{,_{favg,fmin,fmax,ffin}}Australian Apparent TemperatureNumberdegrees
humidity{,_{favg,fmin,fmax,ffin}}HumidityNumber%
wind{,_{favg,fmin,fmax,ffin}}Wind speedNumber-
wind_kmh{,_{favg,fmin,fmax,ffin}}Wind speed. The wind speed in km/hNumber-
direction{,_{favg,fmin,fmax,ffin}}Wind direction, e.g. “NE”Text-

You can use the suffixes noted above to get the following:

SuffixDescription
NoneCurrent weather
_favgAverage forecast value
_fminMinimum forecast value
_fmaxMaximum forecast value
_ffinFinal forecast value
ActionDescriptionDefault button
toggle_formatToggles between format and format_altLeft

§Example

Show detailed weather in San Francisco through the OpenWeatherMap service:

[[block]]
block = "weather"
format = " $icon $weather ($location) $temp, $wind m/s $direction "
format_alt = " $icon_ffin Forecast (9 hour avg) {$temp_favg ({$temp_fmin}-{$temp_fmax})|Unavailable} "
[block.service]
name = "openweathermap"
api_key = "XXX"
city_id = "5398563"
units = "metric"
forecast_hours = 9

§Used Icons

  • weather_sun (when weather is reported as “Clear” during the day)
  • weather_moon (when weather is reported as “Clear” at night)
  • weather_clouds (when weather is reported as “Clouds” during the day)
  • weather_clouds_night (when weather is reported as “Clouds” at night)
  • weather_fog (when weather is reported as “Fog” or “Mist” during the day)
  • weather_fog_night (when weather is reported as “Fog” or “Mist” at night)
  • weather_rain (when weather is reported as “Rain” or “Drizzle” during the day)
  • weather_rain_night (when weather is reported as “Rain” or “Drizzle” at night)
  • weather_snow (when weather is reported as “Snow”)
  • weather_thunder (when weather is reported as “Thunderstorm” during the day)
  • weather_thunder_night (when weather is reported as “Thunderstorm” at night)

Modules§

Structs§

Enums§

Functions§