From b88556c4b78fe0555aadb8b33b4b38d063168684 Mon Sep 17 00:00:00 2001 From: Floris272 Date: Wed, 14 Feb 2024 01:10:19 +0100 Subject: [PATCH 1/2] fix dependency and update readme --- README.md | 56 ++++++++++++++++----------------- pyproject.toml | 4 +-- src/bluecurrent_api/__init__.py | 2 +- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 3f8b270..007c005 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ The library is an asyncio-driven library that interfaces with the Websocket API ### Requirements -- Python 3.9 or newer +- Python 3.11 or newer - websockets -- asyncio +- pytz ### Installation @@ -32,25 +32,25 @@ import asyncio async def main(): - api_token = 'api_token' + api_token = 'VDLAU17BLVKNNK6X2MBUD007MWNHN9R2' client = Client() # data receiver - def on_data(data): + async def on_data(data): print('received: ', data) - # connect to the websocket - await client.connect(api_token) + # validate and set token. + await client.validate_api_token(api_token) # example requests async def requests(): await client.get_charge_points() - await client.wait_for_response() + await asyncio.sleep(10) await client.disconnect() - # start the loop and send requests + # connect and send requests await asyncio.gather( - client.start_loop(on_data), + client.connect(on_data), requests() ) @@ -61,37 +61,33 @@ asyncio.run(main()) --- -The methods validate_token, get_account and get_charge_cards are stand-alone and to be used before connecting to the websocket with connect(). +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) -> bool +#### await validate_token(api_token) -> str - Validates the given token. -#### await get_account() -> bool +#### await get_email() -> str - Returns the account's email. -#### await get_charge_cards(auth_token) -> list - -- Returns the users charge cards. - --- -#### await connect(auth_token) +#### await connect(receiver) - Connects to the websocket. +- Calls get_charge_points and get_charge_cards when connection is established. -#### await start_loop(receiver) - -- Starts the loop and routes the incoming messages to the given receiver method +#### is_connected() -> bool +- Returns if the client is connected -#### await wait_for_response() +#### await wait_for_charge_points() +- Waits until chargepoints are received. -- Waits until the next message is received. -#### get_next_reset_delta() +#### get_next_reset_delta() -> TimeDelta - Returns the timedelta to the next request limit reset (00:00 Europe/Amsterdam). @@ -109,6 +105,10 @@ asyncio.run(main()) - Gets the chargepoints +#### await get_charge_cards() + +- Returns the users charge cards. + #### await get_status(evse_id) - Gets the status from a chargepoint. @@ -127,17 +127,17 @@ asyncio.run(main()) --- -#### await set_public_charging(evse_id, value) +#### await set_linked_charge_cards_only(evse_id, value) -- Sets public charging to True or False. +- Sets set_linked_charge_cards_only. #### await set_plug_and_charge(evse_id, value) -- Sets plug and charge to True or False. +- Sets set_plug_and_charge. -#### await set_operative(evse_id, value) +#### await block(evse_id, value) -- Sets operative to True or False. +- Blocks or unblocks a charge point.
diff --git a/pyproject.toml b/pyproject.toml index e440049..d5f3718 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "bluecurrent-api" -version = "1.2.0" +version = "1.2.1" authors = [ { name="Floris272", email="florispuijk@outlook.com" }, ] @@ -18,7 +18,7 @@ classifiers = [ "Operating System :: OS Independent", ] dependencies = [ - "websockets >= 12.0", + "websockets >= 10.0", "pytz >= 2023.4" ] diff --git a/src/bluecurrent_api/__init__.py b/src/bluecurrent_api/__init__.py index 3e0b029..5928338 100644 --- a/src/bluecurrent_api/__init__.py +++ b/src/bluecurrent_api/__init__.py @@ -1,2 +1,2 @@ """Define module exports.""" -from .client import Client +from .client import Client as Client From c23e525fb0b850f48ef1edf1c9fdcbc6cf1fc296 Mon Sep 17 00:00:00 2001 From: Floris272 Date: Wed, 14 Feb 2024 01:17:40 +0100 Subject: [PATCH 2/2] ignore useless-import-alias --- .pylintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index b78c8ac..e71289b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,2 +1,3 @@ [MASTER] -ignore-patterns=test_*.py \ No newline at end of file +ignore-patterns=test_*.py +disable=useless-import-alias \ No newline at end of file