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.
- Python 3.11 or newer
- websockets
- pytz
pip install bluecurrent-api
Using this library requires a Blue Current api token. You can generate one in the Blue Current driver portal.
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())
The methods validate_token and get_email are stand-alone and are to be used before connecting to the websocket with connect().
- Validates the given token.
- Returns the account's email.
- Connects to the websocket.
- Calls get_charge_points and get_charge_cards when connection is established.
- Returns if the client is connected
- Waits until chargepoints are received.
- Returns the timedelta to the next request limit reset (00:00 Europe/Amsterdam).
- Stops the connection.
- Gets the chargepoints
- Returns the users charge cards.
- Gets the status from a chargepoint.
- Gets the setting states from a chargepoint.
- Gets the grid status from a chargepoint.
- Sets set_linked_charge_cards_only.
- Sets set_plug_and_charge.
- Blocks or unblocks a charge point.
- Resets the chargepoint.
- Reboots the chargepoint.
- Starts a charge session.
- Stops a charge session.