1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
# Blue Current Api
[](https://blue-current-homeassistantapi.readthedocs-hosted.com/en/latest/?badge=latest)
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
```python
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
```python
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
---
<b>The methods validate_token and get_email are stand-alone and are to be used <u>before</u> connecting to the websocket with connect().</b>
<br>
#### 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.
<br>
### 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.
<br>
### 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.
<br>
### 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.
|