yr.no has a great weather service but poor search functionality, especially for South African place names. yr
is a simple CLI that combines OpenStreetMaps search engine with yr's location forecast to provide precise weather forecasts from place names in the command line.
- Provides detailed forecasts for the next 24 hours, summary forecasts for the next
n
days, and forecasts for the next weekend - Enables location search by name and optionally displays a map of the selected location
- Displays forecasts with images and icons in terminal with iTerm2 with automatic fallback to Rich output for other terminals
- Forecasts provide the following information:
- Forecast interval
- Forecast summary icon
- Air temperature (°C)
- Precipitation amount (mm)
- Wind speed (m/s) and direction
- Cloud cover (%)
- Displays forecasts at the highest time resolution available from yr's API (hourly short term, six-hour medium term)
- Allows searches in different countries and handles timezone conversion automatically
pip install yr-cli
You can use the
--help
option to get more details about the commands and their options
yr <command> [options]
Detailed forecast for the next 24 hours
yr now <location>
Options
--limit INTEGER Maximum number of location results [default: 10]
--country-code TEXT Country code for location search [default: za]
--no-cache Bypass cache and fetch fresh data
--map -m Show a map of the selected location
Examples
yr now silvermine Give a detailed forecast for Silvermine, South Africa
yr now silvermine -m --country-code ca Give a detailed forecast for Silvermine, Canada, showing a map
Summary forecast for the next (default 5) days
yr summary <location>
Options
--days INTEGER Number of days for summary forecast [default: 5]
--limit INTEGER Maximum number of location results [default: 10]
--country-code TEXT Country code for location search [default: za]
--no-cache Bypass cache and fetch fresh data
--map -m Show a map of the selected location
Examples
yr summary 'de pakhuys' --limit 5 Give a summary forecast for De Pakhuys, South Africa with at most 5 results
yr summary 'de pakhuys' --days 7 Give a summary forecast for De Pakhuys, South Africa for the next 7 days
Forecast for the next weekend
yr weekend <location>
Options
--limit INTEGER Maximum number of location results [default: 10]
--country-code TEXT Country code for location search [default: za]
--no-cache Bypass cache and fetch fresh data
--map -m Show a map of the selected location
Examples
yr weekend 'sassies bouldering' Give a weekend forecast for Sassies Bouldering, Rocklands, South Africa
Clear the cache of saved locations
yr clear-cache
If you are not using iTerm2, yr
will fallback to using Rich to display the weather table.
To install yr-cli
for development, run:
pip install -e '.[dev]'
Code for this repository is checked using pre-commit. After cloning this repository please run the following steps to initialise pre-commit:
pre-commit install --install-hooks
The following hooks are automatically run when new commits are made:
- From pre-commit hooks:
- end-of-file-fixer
- trailing-whitespace
- check-yaml
- check-added-large-files (max. 500kb)
- black Python code format checking
- flake8 Python code linting
- isort Python code import ordering