Skip to main content

pyopenweathermap

Python library for OpenWeatherMap API for Home Assistant.

One Call API

Use create_owm_client(api_key, 'v3.0') for the combined One Call 3.0 endpoint, or create_owm_client(api_key, 'v4.0') for the separate One Call 4.0 endpoints. Both accept units (default metric) and lang (default en), and expose await client.get_weather(lat, lon) returning a WeatherReport. The current/forecast 2.5 and air-pollution clients remain available.

The 4.0 adapter requests current, timeline/1min, timeline/1h, and timeline/1day, then converts their data arrays to the existing report models. It returns up to 60 minute records, 48 hourly records, and 8 daily records. Missing optional weather fields keep the existing converter defaults; empty data arrays produce empty report sections. Malformed envelopes/records raise RequestError, and a failed endpoint/page fails the report rather than silently returning partially refreshed weather.

Pagination and request budget

A typical complete 4.0 report uses six HTTP requests: current, minutely, three hourly pages (20 + 20 + 8 returned records), and daily. Each page is a separate API call; check account entitlement and budget before enabling 4.0. Short pages can require additional requests. The adapter follows next only while it needs records within the requested count/time horizon, stops on an empty page, removes overlapping records, and rejects repeated links or pages that make no progress. Daily records are capped at eight; it does not fetch the full longer-range 4.0 outlook. Requests are sequential and stop at the first error. No automatic retry is performed.

Only HTTPS pagination links to the same OpenWeather host and timeline endpoint are accepted. Client coordinates, key, units, and language are preserved on all pages. HTTP redirects are not followed, and request URL debug logs redact appid. validate_key() uses one 4.0 current request (or the legacy 3.0 key validation call); authorization errors return False, and other request errors are propagated.

Daily precipitation caveat

The migration guide describes 4.0 daily rain and snow as scalar daily totals in mm, while the reference also lists hourly-shaped rain.1h and snow.1h objects. This adapter accepts nonnegative numeric daily totals and defaults absent fields to zero. It raises a descriptive RequestError for an object or other unsupported value. An hourly rate cannot safely be labeled or multiplied into a daily total. The 3.0 converter behavior is unchanged. Confirm this ambiguity with a sanitized live response before claiming production validation.

Reference: One Call 4.0 endpoints and pagination. Weather alerts and 15-minute forecasts are outside the existing report model.

Development and testing

Use Python 3.11+ and Poetry (poetry install). The project uses poetry.lock. The default suite and CI are offline and do not require an API key:

poetry run pytest
poetry run pytest -m 'not network'
poetry build

Fixtures are synthetic, source-labeled contract examples, not recordings of successful authenticated calls. Unmarked tests block socket connections and DNS. Run credentialed smoke tests only when you have approved account access, 4.0 entitlement, and a request budget; they are explicitly opt-in:

# Supply OWM_API_KEY through your local environment, not source control.
poetry run pytest -m network

The existing skipped legacy smoke tests remain skipped. Offline tests establish adapter behavior against the published contract; they do not verify an account's entitlement, actual provider responses, Home Assistant integration, or deployment.

Metadata

Release files for pyopenweathermap 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyopenweathermap 0.3.1
File Size Uploaded Provenance Actions
pyopenweathermap-0.3.1.tar.gz 10.1 kB Without provenance Details for pyopenweathermap-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyopenweathermap 0.3.1
File Interpreter ABI Platform Actions
pyopenweathermap-0.3.1-py3-none-any.whl Python 3 none any Details for pyopenweathermap-0.3.1-py3-none-any.whl

Total release size: 22.8 kB

Release files / pyopenweathermap-0.3.1.tar.gz

Download URL pyopenweathermap-0.3.1.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
281d96e821ecf1624a61c536d8a74bfd2ceac828ffadf0724181c893c3f893a9
BLAKE2b-256 checksum
How to use checksums
d3ecfabcc23d528ac9cdd4138b05641dcf3c713222666e4651f48bcff133dc05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.11.18 Linux/7.0.0-1019-azure

Release files / pyopenweathermap-0.3.1-py3-none-any.whl

Download URL pyopenweathermap-0.3.1-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2ac58387948c6b69e850ca0c5d99ab56d3a95736b90c80a6ed8ae624b2432b4
BLAKE2b-256 checksum
How to use checksums
966b6fcf57116deb1d7ceefe715a1836aa0918d53f02ae47e68900b256518d76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.11.18 Linux/7.0.0-1019-azure

Security for pyopenweathermap 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page