Async Python client for the Servicio Meteorológico Nacional Argentina (SMN) API
Project description
py-ha-smn
Async Python client for the Servicio Meteorológico Nacional Argentina (SMN) API.
This library is designed for use with Home Assistant.
Installation
pip install py-ha-smn
Usage
import aiohttp
from smn_argentina_api import SMNApiClient, SMNTokenManager
async def main():
async with aiohttp.ClientSession() as session:
# Create token manager and API client
token_manager = SMNTokenManager(session)
client = SMNApiClient(session, token_manager)
# Get location ID from coordinates
location = await client.async_get_location(-34.6037, -58.3816)
location_id = str(location.get("id"))
# Fetch current weather
weather = await client.async_get_current_weather(location_id)
print(f"Temperature: {weather.get('temperature')}°C")
# Fetch forecast
forecast = await client.async_get_forecast(location_id)
print(f"Forecast days: {len(forecast.get('forecast', []))}")
# Fetch alerts
alerts = await client.async_get_alerts(location_id)
print(f"Warnings: {len(alerts.get('warnings', []))}")
if __name__ == "__main__":
import asyncio
asyncio.run(main())
API Methods
SMNApiClient
async_get_location(latitude, longitude)- Get location ID from coordinatesasync_get_current_weather(location_id)- Fetch current weather dataasync_get_forecast(location_id)- Fetch weather forecastasync_get_alerts(location_id)- Fetch weather alertsasync_get_shortterm_alerts(location_id)- Fetch short-term severe weather alertsasync_get_heat_warnings(area_id)- Fetch heat warnings
SMNTokenManager
Handles JWT token authentication with the SMN API. Automatically refreshes tokens before expiration.
Exceptions
SMNError- Base exception for all SMN API errorsSMNConnectionError- Connection to SMN API failedSMNAuthenticationError- Authentication with SMN API failedSMNTokenError- Token fetching or parsing failed
License
Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_ha_smn-1.0.0.tar.gz.
File metadata
- Download URL: py_ha_smn-1.0.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e6b1671b613472a1510b0eee5f0321f242d45c8e831d7757b107e3c4d3ed8ec
|
|
| MD5 |
f1bae8b6672c737ab0c7abccdfd9be40
|
|
| BLAKE2b-256 |
840115c81bfd330419cf229e332e13308fa7a3c36046af61c00e1df4de352b7d
|
Provenance
The following attestation bundles were made for py_ha_smn-1.0.0.tar.gz:
Publisher:
workflow.yaml on catastrophicode/py-ha-smn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ha_smn-1.0.0.tar.gz -
Subject digest:
1e6b1671b613472a1510b0eee5f0321f242d45c8e831d7757b107e3c4d3ed8ec - Sigstore transparency entry: 833970821
- Sigstore integration time:
-
Permalink:
catastrophicode/py-ha-smn@a92ebe2f3d7881e24c2a506347df54aa06e664df -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/catastrophicode
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yaml@a92ebe2f3d7881e24c2a506347df54aa06e664df -
Trigger Event:
release
-
Statement type:
File details
Details for the file py_ha_smn-1.0.0-py3-none-any.whl.
File metadata
- Download URL: py_ha_smn-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6616e26c59e02310951c44af33668e545188410722414a0cda09d2fb07359c2
|
|
| MD5 |
89035fe779448422b978b4a7fad38b98
|
|
| BLAKE2b-256 |
9f55e762b73a0523e36c76784f0c01a462445c4c9ba544d185e1e2a433cbd847
|
Provenance
The following attestation bundles were made for py_ha_smn-1.0.0-py3-none-any.whl:
Publisher:
workflow.yaml on catastrophicode/py-ha-smn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ha_smn-1.0.0-py3-none-any.whl -
Subject digest:
f6616e26c59e02310951c44af33668e545188410722414a0cda09d2fb07359c2 - Sigstore transparency entry: 833970834
- Sigstore integration time:
-
Permalink:
catastrophicode/py-ha-smn@a92ebe2f3d7881e24c2a506347df54aa06e664df -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/catastrophicode
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yaml@a92ebe2f3d7881e24c2a506347df54aa06e664df -
Trigger Event:
release
-
Statement type: