Skip to content

Commit

Permalink
Update readme (#96)
Browse files Browse the repository at this point in the history
* docs: update README with connection instructions and development set-up push

Signed-off-by: Vlad Iftime <[email protected]>
Signed-off-by: Vlad Iftime <[email protected]>

* Update to Readme about installing for testing and for running  on different ports

Signed-off-by: Vlad Iftime <[email protected]>
Signed-off-by: Vlad Iftime <[email protected]>

* Fix PR: flake8

Signed-off-by: Vlad Iftime <[email protected]>
Signed-off-by: Vlad Iftime <[email protected]>

* Fix PR: Test

Signed-off-by: Vlad Iftime <[email protected]>
Signed-off-by: Vlad Iftime <[email protected]>

* Fix PR: Test. Weird regex check fail

Signed-off-by: Vlad Iftime <[email protected]>
Signed-off-by: Vlad Iftime <[email protected]>

* Fix PR: Test. Weird regex check fail

Signed-off-by: Vlad Iftime <[email protected]>
Signed-off-by: Vlad Iftime <[email protected]>

* Fix PR: Test. Weird regex check fail

Signed-off-by: Vlad Iftime <[email protected]>
Signed-off-by: Vlad Iftime <[email protected]>

* Update README: Add instructions for retrieving user and account information

Signed-off-by: Vlad Iftime <[email protected]>
Signed-off-by: Vlad Iftime <[email protected]>

---------

Signed-off-by: Vlad Iftime <[email protected]>
Signed-off-by: Vlad Iftime <[email protected]>
  • Loading branch information
VladIftime authored Dec 25, 2024
1 parent faece1e commit ae7c9b0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
19 changes: 19 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ To get started with the FlexMeasures Client package, first an account needs to b
To create a local instance of FlexMeasures, follow the `FlexMeasures documentation <https://flexmeasures.readthedocs.io/en/latest/index.html>`_.
Registering to a hosted FlexMeasures instance instead can be done through `Seita BV <https://seita.nl/>`_.

In this example we are connecting to ``localhost:5000``, To connect to a different host add the host in the initialization of the client.

Install using ``pip``::

pip install flexmeasures-client
Expand Down Expand Up @@ -111,6 +113,17 @@ Trigger a schedule::
sensor_id=<sensor_id>, # int
start="2023-03-26T10:00+02:00", # iso datetime
duration="PT12H", # iso timedelta
flex_context= {"consumption-price-sensor": <consumption_price_sensor_id>, # int},
flex-model= {
"soc-unit": "kWh",
"soc-at-start": 50, # soc_units (kWh)
"soc-max": 400,
"soc-min": 20,
"soc-targets": [
{"value": 100, "datetime": "2023-03-03T11:00+02:00"}
],
}
duration="PT12H", # iso timedelta
flex_context= {"consumption-price-sensor": <consumption_price_sensor_id>}, # int
flex-model= {
"soc-unit": "kWh",
Expand All @@ -135,6 +148,12 @@ The schedule returns a Pandas ``DataFrame`` that can be used to regulate the fle



Development
==============

If you want to develop this package it's necessary to install testing requirements::

pip install -e ".[testing]"

.. _pyscaffold-notes:

Expand Down
8 changes: 4 additions & 4 deletions src/flexmeasures_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ def __post_init__(self):
if re.match(r"^http\:\/\/", self.host):
host_without_scheme = self.host.removeprefix("http://")
raise WrongHostError(
f"http:// should not be included in {self.host}."
f"http: // should not be included in {self.host}. "
f"Instead use host={host_without_scheme}"
)
if re.match(r"^https\:\/\/", self.host):
host_without_scheme = self.host.removeprefix("https://")
raise WrongHostError(
f"https:// should not be included in {self.host}."
f"To use https:// set ssl=True and host={host_without_scheme}"
f"https: // should not be included in {self.host}."
f"To use https: // set ssl=True and host={host_without_scheme}"
)
if len(self.password) < 1:
raise EmptyPasswordError("password cannot be empty")
Expand Down Expand Up @@ -119,7 +119,7 @@ async def request(
Retries if:
- the client request timed out (as indicated by the client's self.request_timeout)
- the server response indicates a 408 (Request Timeout) status
- the server response indicates a 503 (Service Unavailable) status with a Retry-After response header
- the server response indicates a 503 (Service Unavailable) status with a Retry-After response header.
Fails if:
- the server response indicated a status code of 400 or higher
Expand Down
3 changes: 1 addition & 2 deletions src/flexmeasures_client/response_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ async def check_response(
status: {status}
headers: {headers}
payload: {payload}.
Re-authenticating!
"""
Re-authenticating!"""
logging.debug(message)
await self.get_access_token()
reauth_once = False
Expand Down
6 changes: 3 additions & 3 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test__init__(
"password": "test_password",
},
WrongHostError,
"http:// should not be included in http://test." "Instead use host=test",
"http: // should not be included in http://test." " Instead use host=test",
),
(
{
Expand All @@ -115,8 +115,8 @@ def test__init__(
"password": "test_password",
},
WrongHostError,
"https:// should not be included in https://test."
"To use https:// set ssl=True and host=test",
"https: // should not be included in https://test."
"To use https: // set ssl=True and host=test",
),
(
{
Expand Down

0 comments on commit ae7c9b0

Please sign in to comment.