From 6a69a71649ca2128973bc2d441ae6d5c74581f6d Mon Sep 17 00:00:00 2001 From: Krisjanis Lejejs Date: Mon, 26 Dec 2022 17:14:04 +0200 Subject: [PATCH] Move example file credentials to a separate file --- README.md | 4 +++- credentials.py | 2 ++ example.py | 8 +++++--- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 credentials.py diff --git a/README.md b/README.md index 44187f7..244ac85 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,9 @@ Thus, I have created a `debug()` function that runs when `example.py` is execute * `genesis`, online access url is https://online-genesis.thermia.se ## How to use api: -See [example.py](https://github.com/klejejs/python-thermia-online-api/blob/main/example.py) file +See [example.py](https://github.com/klejejs/python-thermia-online-api/blob/main/example.py) file for examples. + +To execute the example file, first run `pip install -r requirements.txt` to install the required dependencies, then run `python3 example.py` to execute the example file. You will be prompted to enter your username and password, and then the example file will run. If do not want to manually enter your credentials every time, you can edit the `credentials.py` file and add your credentials there. ## Available functions in Thermia class: | Function | Description | diff --git a/credentials.py b/credentials.py new file mode 100644 index 0000000..92b1dfa --- /dev/null +++ b/credentials.py @@ -0,0 +1,2 @@ +USERNAME = "" +PASSWORD = "" diff --git a/example.py b/example.py index 2ec57e6..dff10b9 100644 --- a/example.py +++ b/example.py @@ -1,10 +1,12 @@ from datetime import datetime, timedelta from ThermiaOnlineAPI import Thermia +from credentials import USERNAME, PASSWORD -USERNAME = "demo" -PASSWORD = "demo" +CHANGE_HEAT_PUMP_DATA_DURING_TEST = False # Set to True if you want to change heat pump data during test -CHANGE_HEAT_PUMP_DATA_DURING_TEST = True +if not USERNAME or not PASSWORD: + USERNAME = input("Enter username: ") + PASSWORD = input("Enter password: ") thermia = Thermia(USERNAME, PASSWORD, "classic")