Skip to main content

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

Project description

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

Configuration

Find the EV charger(s) you want to monitor here: https://shellrecharge.com/en-gb/find-a-charge-point look for the Serial number under details section. Then use Add device within Home Assistant and enter the Serial number in the form.

Example:

image

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

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

shellrecharge-0.1.19.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

shellrecharge-0.1.19-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file shellrecharge-0.1.19.tar.gz.

File metadata

  • Download URL: shellrecharge-0.1.19.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for shellrecharge-0.1.19.tar.gz
Algorithm Hash digest
SHA256 f7a32a1250b35590dee50476ac4d0cadbf51aeeeae20e5e2fc2e86921865f494
MD5 f95180bc21ab3ec07f8861cb30ed048a
BLAKE2b-256 77e58b80fbc2186e26da3901d9dd90d52670b53c425093b01aad8e95fb61d6bb

See more details on using hashes here.

File details

Details for the file shellrecharge-0.1.19-py3-none-any.whl.

File metadata

File hashes

Hashes for shellrecharge-0.1.19-py3-none-any.whl
Algorithm Hash digest
SHA256 5d24f4cf59816852042cc6fe9dede5f5a03c0c445246415100f9e38fc3602740
MD5 d115777a87a125098933ea7e556d9dca
BLAKE2b-256 b73a13d3bca3825d77090b5d5428d42962a021192928df3d312e8d942fd2f1f8

See more details on using hashes here.

Supported by

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