Skip to main content

Python library to retrieve data from Grand Lyon open data platform, for Home Assistant.

Project description

data_grand_lyon_ha

Python library to retrieve data from the Grand Lyon open data platform.

Intended for use as a Home Assistant integration backend.

Installation

pip install data-grand-lyon-ha

Or with uv:

uv add data-grand-lyon-ha

Usage

import asyncio
import aiohttp
from data_grand_lyon_ha import (
    DataGrandLyonClient,
    filter_tcl_passages_by_line,
    filter_tcl_passages_by_stop,
    find_tcl_stop_by_id,
    find_velov_station_by_id,
    sort_tcl_passages_by_time,
)

async def main():
    async with aiohttp.ClientSession() as session:
        client = DataGrandLyonClient(session)
        # Or with authentication (required for real-time TCL passages):
        # client = DataGrandLyonClient(session, username="user", password="pass")

        # TCL passages: fetch all, then filter and sort client-side
        all_passages = await client.get_tcl_passages()
        passages = filter_tcl_passages_by_stop(
            filter_tcl_passages_by_line(all_passages, "A"), 30101
        )
        for p in sort_tcl_passages_by_time(passages):
            print(f"{p.ligne}{p.direction} in {p.delai_passage} [{p.type}]")

        # TCL stops: fetch all, then look one up by ID
        stops = await client.get_tcl_stops()
        stop = find_tcl_stop_by_id(stops, 1041)
        if stop:
            print(f"{stop.nom} ({stop.commune}) — lines: {stop.desserte}")

        # Vélo'v stations: fetch all, then look one up by ID
        stations = await client.get_velov_stations()
        station = find_velov_station_by_id(stations, 10044)
        if station:
            print(
                f"{station.name}: {station.available_bikes}/{station.bike_stands} bikes"
            )

asyncio.run(main())

Development

This project uses uv for dependency management.

# Run tests
uv run pytest

# Build the package
uv build

License

MIT

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

data_grand_lyon_ha-0.8.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

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

data_grand_lyon_ha-0.8.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file data_grand_lyon_ha-0.8.0.tar.gz.

File metadata

  • Download URL: data_grand_lyon_ha-0.8.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for data_grand_lyon_ha-0.8.0.tar.gz
Algorithm Hash digest
SHA256 72d2a105035e72ef2178cc34a3ae1efeffbc7ac35a74211c7e44d36f53394aa9
MD5 6c98b87344f9312aabba5bc899b54ef2
BLAKE2b-256 8bf0adbd689a37b531bebd3b340290b55654b5c8ea4aa0660158994e76fb01f2

See more details on using hashes here.

File details

Details for the file data_grand_lyon_ha-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: data_grand_lyon_ha-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for data_grand_lyon_ha-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb5f322b89fedb57d67e1ae280a0a45055931937950dd4547600a57108237d64
MD5 36b878e21d868bc729388799275c816c
BLAKE2b-256 decbd6c48462f7539c112f0c4545c2cacc06100dc4bc6af2756bdd78ce7c3418

See more details on using hashes here.

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