Skip to content

Commit 1e6bbf4

Browse files
committed
Remove separate Genesis API config
1 parent d48f9a6 commit 1e6bbf4

6 files changed

Lines changed: 9 additions & 44 deletions

File tree

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ Thus, I have created a `debug()` function that runs when `example.py` is execute
1010

1111
**Note:** I have done my best to remove the sensitive parts from debugging, but I do not guarantee that no sensitive data is printed to the debug file. I have no intention of using it maliciously, but if you post the file publicly on GitHub, please make sure you remove anything you feel might be suspicious of sharing.
1212

13-
## Supported APIs:
14-
* `classic`, default, online access url is https://online.thermia.se
15-
* `genesis`, online access url is https://online-genesis.thermia.se
16-
1713
## How to use api:
1814
See [example.py](https://github.com/klejejs/python-thermia-online-api/blob/main/example.py) file for examples.
1915

ThermiaOnlineAPI/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
from ThermiaOnlineAPI.api.ThermiaAPI import ThermiaAPI
44
from ThermiaOnlineAPI.exceptions import AuthenticationException, NetworkException
55
from ThermiaOnlineAPI.model.HeatPump import ThermiaHeatPump
6-
from ThermiaOnlineAPI.const import THERMIA_API_TYPE_CLASSIC
76

87

98
class Thermia:
10-
def __init__(self, username, password, api_type=THERMIA_API_TYPE_CLASSIC):
9+
def __init__(self, username, password):
1110
self._username = username
1211
self._password = password
1312

14-
self.api_interface = ThermiaAPI(username, password, api_type)
13+
self.api_interface = ThermiaAPI(username, password)
1514
self.connected = self.api_interface.authenticated
1615

1716
self.heat_pumps = self.fetch_heat_pumps()

ThermiaOnlineAPI/api/ThermiaAPI.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
REG_HOT_WATER_STATUS,
1818
REG__HOT_WATER_BOOST,
1919
REG_OPERATIONMODE,
20-
THERMIA_API_CONFIG_URLS_BY_API_TYPE,
20+
THERMIA_CONFIG_URL,
2121
THERMIA_AZURE_AUTH_URL,
2222
THERMIA_AZURE_AUTH_CLIENT_ID_AND_SCOPE,
2323
THERMIA_AZURE_AUTH_REDIRECT_URI,
@@ -47,7 +47,7 @@
4747

4848

4949
class ThermiaAPI:
50-
def __init__(self, email, password, api_type):
50+
def __init__(self, email, password):
5151
self.__email = email
5252
self.__password = password
5353
self.__token = None
@@ -69,11 +69,6 @@ def __init__(self, email, password, api_type):
6969
adapter = HTTPAdapter(max_retries=retry)
7070
self.__session.mount("https://", adapter)
7171

72-
if api_type not in THERMIA_API_CONFIG_URLS_BY_API_TYPE:
73-
raise ValueError("Unknown device type: " + api_type)
74-
75-
self.__api_config_url = THERMIA_API_CONFIG_URLS_BY_API_TYPE[api_type]
76-
7772
self.configuration = self.__fetch_configuration()
7873
self.authenticated = self.__authenticate()
7974

@@ -514,7 +509,7 @@ def __set_register_value(
514509
)
515510

516511
def __fetch_configuration(self):
517-
request = self.__session.get(self.__api_config_url)
512+
request = self.__session.get(THERMIA_CONFIG_URL)
518513
status = request.status_code
519514

520515
if status != 200:

ThermiaOnlineAPI/const.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,16 @@
22
# General configuration
33
###############################################################################
44

5-
THERMIA_CLASSIC_API_CONFIG_URL = "https://online.thermia.se/api/configuration"
6-
THERMIA_GENESIS_API_CONFIG_URL = "https://online-genesis.thermia.se/api/configuration"
7-
5+
THERMIA_CONFIG_URL = "https://online.thermia.se/api/configuration"
86
THERMIA_INSTALLATION_PATH = "/api/v1/Registers/Installations/"
97

10-
THERMIA_API_TYPE_CLASSIC = "classic"
11-
THERMIA_API_TYPE_GENESIS = "genesis"
12-
13-
THERMIA_API_CONFIG_URLS_BY_API_TYPE = {
14-
THERMIA_API_TYPE_CLASSIC: THERMIA_CLASSIC_API_CONFIG_URL,
15-
THERMIA_API_TYPE_GENESIS: THERMIA_GENESIS_API_CONFIG_URL,
16-
}
17-
188
###############################################################################
199
# Azure AD configuration
2010
###############################################################################
2111

2212
THERMIA_AZURE_AUTH_URL = "https://thermialogin.b2clogin.com/thermialogin.onmicrosoft.com/b2c_1a_signuporsigninonline"
2313
THERMIA_AZURE_AUTH_CLIENT_ID_AND_SCOPE = "09ea4903-9e95-45fe-ae1f-e3b7d32fa385"
24-
THERMIA_AZURE_AUTH_REDIRECT_URI = "https://online-genesis.thermia.se/login"
14+
THERMIA_AZURE_AUTH_REDIRECT_URI = "https://online.thermia.se/login"
2515

2616
###############################################################################
2717
# Register groups

credentials.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
USERNAME = ""
22
PASSWORD = ""
3-
API_TYPE = "" # classic or genesis

example.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
from datetime import datetime, timedelta
22
from ThermiaOnlineAPI import Thermia
3-
from credentials import USERNAME, PASSWORD, API_TYPE
4-
from ThermiaOnlineAPI.const import (
5-
THERMIA_API_TYPE_CLASSIC,
6-
THERMIA_API_TYPE_GENESIS,
7-
)
3+
from credentials import USERNAME, PASSWORD
84

95
CHANGE_HEAT_PUMP_DATA_DURING_TEST = (
106
False # Set to True if you want to change heat pump data during test
@@ -14,17 +10,7 @@
1410
USERNAME = input("Enter username: ")
1511
PASSWORD = input("Enter password: ")
1612

17-
if not API_TYPE:
18-
api_type_number = input("Enter api type (1 = classic, 2 = genesis): ")
19-
if api_type_number == "1":
20-
API_TYPE = THERMIA_API_TYPE_CLASSIC
21-
elif api_type_number == "2":
22-
API_TYPE = THERMIA_API_TYPE_GENESIS
23-
else:
24-
print("Invalid api type")
25-
exit(1)
26-
27-
thermia = Thermia(USERNAME, PASSWORD, api_type=API_TYPE)
13+
thermia = Thermia(USERNAME, PASSWORD)
2814

2915
print("Connected: " + str(thermia.connected))
3016

0 commit comments

Comments
 (0)