Skip to content

Python 3 package to retrieve public EV charger data from Shell Recharge

License

Notifications You must be signed in to change notification settings

cyberjunky/python-shellrecharge

Repository files navigation

Python: Shell Recharge

Python 3 package to retrieve public EV charger data from Shell Recharge

GitHub Release GitHub Activity License

Project Maintenance

About

This package allows you to request data from public EV chargers using Shell Recharge. I build it to create a home-assistant integration, it can be done with rest calls only, but then options are limited.

Installation

pip3 install shellrecharge

Development

To create a development environment to commit code.

python3 -m venv .venv
source .venv/bin/activate
pip3 install pdm
pip3 install ruff
pdm init

sudo apt install pre-commit
pip3 install pre-commit

Run checks before PR/Commit:

make all

Example

Below provides example on how to use the library.

#!/usr/bin/env python3
"""Example code."""
import asyncio
import logging
import sys
from asyncio import CancelledError

import aiohttp
from aiohttp.client_exceptions import ClientError

import shellrecharge
from shellrecharge import LocationEmptyError, LocationValidationError


async def main():
    """Main module."""

    # Some random stations
    location_ids = ["9b9428ab-1dfd-4230-a024-084eacf776ff", "682154", "9cf6c16b-b043-4ba8-b7ca-872f82a0faf4"]

    async with aiohttp.ClientSession() as session:
        try:
            api = shellrecharge.Api(session)
            for location_id in location_ids:
                location = await api.location_by_id(location_id)
                logging.info(location)
        except LocationEmptyError:
            logging.error("No data returned, check location id")
        except LocationValidationError as err:
            logging.error("Location validation error {}, report locaton id" % err)
        except (ClientError, TimeoutError, CancelledError) as err:
            logging.error(err)


if __name__ == "__main__":
    logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
    loop = asyncio.new_event_loop()
    loop.run_until_complete(main())

Donations

Donate Sponsor

About

Python 3 package to retrieve public EV charger data from Shell Recharge

Resources

License

Stars

Watchers

Forks

Packages

No packages published