A wrapper for the Blue Current websocket api
Project description
Blue Current Api
Python wrapper for the blue current api
The library is an asyncio-driven library that interfaces with the Websocket API provided by Blue Current. This was made for the Blue Current Home Assistant integration.
Usage
Requirements
- Python 3.11 or newer
- websockets
- pytz
Installation
pip install bluecurrent-api
Api token
Using this library requires a Blue Current api token. You can generate one in the Blue Current driver portal.
Example
from bluecurrent_api import Client
import asyncio
async def main():
api_token = 'api_token'
client = Client()
# data receiver
async def on_data(data):
print('received: ', data)
# validate and set token.
await client.validate_api_token(api_token)
# example requests
async def requests():
await client.get_charge_points()
await asyncio.sleep(10)
await client.disconnect()
# connect and send requests
await asyncio.gather(
client.connect(on_data),
requests()
)
asyncio.run(main())
Implemented methods
The methods validate_token and get_email are stand-alone and are to be used before connecting to the websocket with connect().
await validate_token(api_token) -> str
- Validates the given token.
await get_email() -> str
- Returns the account's email.
await connect(receiver)
- Connects to the websocket.
- Calls get_charge_points and get_charge_cards when connection is established.
is_connected() -> bool
- Returns if the client is connected
await wait_for_charge_points()
- Waits until chargepoints are received.
get_next_reset_delta() -> TimeDelta
- Returns the timedelta to the next request limit reset (00:00 Europe/Amsterdam).
await disconnect()
- Stops the connection.
Data
await get_charge_points()
- Gets the chargepoints
await get_charge_cards()
- Returns the users charge cards.
await get_status(evse_id)
- Gets the status from a chargepoint.
await get_settings(evse_id)
- Gets the setting states from a chargepoint.
await get_grid_status(evse_id)
- Gets the grid status from a chargepoint.
Settings
await set_linked_charge_cards_only(evse_id, value)
- Sets set_linked_charge_cards_only.
await set_plug_and_charge(evse_id, value)
- Sets set_plug_and_charge.
await block(evse_id, value)
- Blocks or unblocks a charge point.
Actions
await reset(evse_id)
- Resets the chargepoint.
await reboot(evse_id)
- Reboots the chargepoint.
await start_session(evse_id card_uid)
- Starts a charge session.
await stop_session(evse_id)
- Stops a charge session.
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
bluecurrent-api-1.2.3.tar.gz
(13.4 kB
view details)
Built Distribution
File details
Details for the file bluecurrent-api-1.2.3.tar.gz
.
File metadata
- Download URL: bluecurrent-api-1.2.3.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99645348c4baf3e2756783d838517f52fa1f4aa575c2fd208e24c00845837cd8 |
|
MD5 | 378fd35cbe6c9de11afde932ba35ff60 |
|
BLAKE2b-256 | c68dc54357cdcf745ecd156058015ebfb715978dfeb95895fab2c709510ec24b |
File details
Details for the file bluecurrent_api-1.2.3-py3-none-any.whl
.
File metadata
- Download URL: bluecurrent_api-1.2.3-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d69d5c5dbfed5cd4c5dbd3cd59bd2e661471aaec0b8f5ba9fb42eae435fbc88e |
|
MD5 | 34115db2eb5debcc6e67c8accd6f3586 |
|
BLAKE2b-256 | 7e7e4d341767acc1cc0418425ca4ba830050c99a73fbcb679ee29cdd11e70b45 |