Skip to main content

Async integration layer between Home Assistant and Dutch municipal visitor parking APIs.

Project description

pyCityVisitorParking

PyPI version Python versions CI

Async integration layer between Home Assistant and Dutch municipal visitor parking APIs.

Status

This package ships the core client, provider interface, and discovery tooling, plus the following providers:

  • DVS Portal
  • The Hague

list_providers() reads provider manifests under src/pycityvisitorparking/provider/.

Provider documentation:

Supported municipalities

For exact base_url and api_uri values, see the provider READMEs.

  • DVS Portal: Apeldoorn, Bloemendaal, Delft, Den Bosch, Doetinchem (via Buha), Groningen, Haarlem, Harlingen, Heemstede, Heerenveen, Heerlen, Hengelo, Katwijk, Leiden, Leidschendam-Voorburg, Middelburg, Nissewaard, Oldenzaal, Rijswijk, Roermond, Schouwen-Duiveland, Sittard-Geleen, Smallingerland, Sudwest-Fryslan, Veere, Venlo, Vlissingen, Waadhoeke, Waalwijk, Weert, Zaanstad, Zevenaar, Zutphen, Zwolle
  • The Hague: The Hague

Installation

Requires Python 3.13+.

pip install pycityvisitorparking

Quickstart

import asyncio

from pycityvisitorparking import Client


async def main() -> None:
    async with Client(base_url="https://example") as client:
        provider = await client.get_provider("dvsportal")
        await provider.login(credentials={"username": "user", "password": "secret"})
        permit = await provider.get_permit()
        print(permit)


asyncio.run(main())

Usage

import asyncio

from pycityvisitorparking import Client


async def main() -> None:
    async with Client() as client:
        providers = await client.list_providers()
        print(providers)


asyncio.run(main())

Configuration

  • base_url is required for provider requests.
  • api_uri is optional; providers may define a default (see provider README).
  • Credentials are standardized: username and password are required.
  • Provider-specific optional fields (for example permit_media_type_id) are documented in each provider README.

Async behavior

Provider discovery (list_providers(), get_provider()) runs in background threads so async callers avoid blocking the event loop.

Available data

The public API exposes a small, provider-agnostic set of models and operations. Provider READMEs list credential requirements and any unsupported operations.

  • Providers: list_providers() returns ProviderInfo with id and favorite_update_possible.
  • Permit: get_permit() returns Permit with id, remaining_balance (minutes), and zone_validity.
  • Zone validity: each ZoneValidityBlock includes start_time and end_time (UTC ISO 8601).
  • Reservations: list_reservations(), start_reservation(), update_reservation(), and end_reservation() return Reservation with id, name, license_plate, start_time, and end_time.
  • Favorites: list_favorites() and add_favorite() return Favorite with id, name, and license_plate. update_favorite() returns Favorite when supported (favorite_update_possible), otherwise it raises ProviderError. remove_favorite() removes the entry without returning data.

Provider framework

Providers are discovered via manifest.json files without importing provider modules. Discovery runs in a background thread to avoid blocking the event loop. To add a provider later, create:

src/pycityvisitorparking/provider/<provider_id>/
  manifest.json
  __init__.py
  api.py
  const.py
  README.md
  CHANGELOG.md

Only files under src/pycityvisitorparking/provider/<provider_id>/ should change in a provider PR.

Manifest loading is cached (5-minute TTL); pass refresh=True or call clear_manifest_cache() to force a reload. If you use loader helpers directly, prefer their async_* variants to avoid blocking the event loop.

Credential inputs are standardized: pass username and password to login() for all providers. Provider READMEs list any optional fields such as permit_media_type_id.

Error handling

Public methods raise library exceptions instead of raw aiohttp errors:

  • AuthError: authentication failures (HTTP 401/403 or provider auth rejection).
  • NetworkError: network/timeout failures.
  • ValidationError: invalid inputs (timestamps, plates, missing fields).
  • ProviderError: provider responses or request failures not covered above.

Exception messages avoid credentials and full license plates.

Example handling:

from pycityvisitorparking import Client
from pycityvisitorparking.exceptions import AuthError, NetworkError, ProviderError, ValidationError

async with Client(base_url=base_url, api_uri=api_uri) as client:
    try:
        provider = await client.get_provider("dvsportal")
        await provider.login(credentials={"username": "user", "password": "secret"})
        permit = await provider.get_permit()
    except (AuthError, ValidationError) as exc:
        handle_auth_or_input_error(exc)
    except NetworkError as exc:
        handle_network_issue(exc)
    except ProviderError as exc:
        handle_provider_issue(exc)

Normalization rules

  • Public APIs accept only timezone-aware datetime values; naive timestamps raise ValidationError.
  • All public timestamps are normalized to UTC ISO 8601 with Z and second precision (microseconds are truncated).
  • Internally, reservation times are handled as timezone-aware UTC datetime values and serialized to strings only at provider and model boundaries.
  • License plates are normalized to uppercase A-Z0-9 without spaces/symbols.
  • zone_validity must include only chargeable windows.

Development

Run checks with Hatch:

hatch run lint:check
hatch run lint:format-check
hatch run test:run

Build artifacts:

hatch build
python -m twine check dist/*

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycityvisitorparking-0.5.1.tar.gz (38.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycityvisitorparking-0.5.1-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file pycityvisitorparking-0.5.1.tar.gz.

File metadata

  • Download URL: pycityvisitorparking-0.5.1.tar.gz
  • Upload date:
  • Size: 38.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycityvisitorparking-0.5.1.tar.gz
Algorithm Hash digest
SHA256 0727ebc9d115d63a8c3a17424d4ce4afbaf662baa385e532611115a47c3446f1
MD5 8b2422221995386149d71db4ddf93898
BLAKE2b-256 27c8de0e1c8b3f1016f5be0a0768ff0ff0befa31ed5da0f7a415952a1cebe795

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycityvisitorparking-0.5.1.tar.gz:

Publisher: release.yml on sir-Unknown/pyCityVisitorParking

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycityvisitorparking-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pycityvisitorparking-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c85e9327bf84ca8160a02bed6b5898730fe9dd836f6923c69d92d3d3425aa779
MD5 de39d51b14476efe01c80f0bcb3a8aae
BLAKE2b-256 d710b7d1f640fcc8ab8839a9018fa0db9214440f74ad7d95041e571cab89c960

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycityvisitorparking-0.5.1-py3-none-any.whl:

Publisher: release.yml on sir-Unknown/pyCityVisitorParking

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page