|
| 1 | +import os |
| 2 | +from ThermiaOnlineAPI import Thermia |
| 3 | + |
| 4 | +TEST_EXCLUDED_LINE_STRINGS = [ |
| 5 | + # self.__info related |
| 6 | + "lastOnline", |
| 7 | + "activeAlarms", |
| 8 | + "activeCriticalAlarms", |
| 9 | + "unreadErrors", |
| 10 | + "unreadInfo", |
| 11 | + "unreadWarnings", |
| 12 | + # self.__status related |
| 13 | + "dcmVersion", |
| 14 | + "heatingEffect", |
| 15 | + "hotWaterTemperature", |
| 16 | + "indoorTemperature", |
| 17 | + "isHotWaterActive", |
| 18 | + "isOutdoorTempSensorFunctioning", |
| 19 | + "outdoorTemperature", |
| 20 | + "programVersion", |
| 21 | + "reducedHeatingEffect", |
| 22 | + # self.__device_data related |
| 23 | + "firmwareVersion", |
| 24 | + "lastOnline", |
| 25 | + # Register group related |
| 26 | + "registerValue", |
| 27 | + "timeStamp", |
| 28 | + "value", |
| 29 | +] |
| 30 | + |
| 31 | + |
| 32 | +def test_excluded_string_in_line(line: str) -> bool: |
| 33 | + for excluded_string in TEST_EXCLUDED_LINE_STRINGS: |
| 34 | + if excluded_string in line: |
| 35 | + return True |
| 36 | + return False |
| 37 | + |
| 38 | + |
| 39 | +USERNAME = None |
| 40 | +PASSWORD = None |
| 41 | + |
| 42 | +with open(".env", "r") as env_file: |
| 43 | + for line in env_file: |
| 44 | + if line.startswith("USERNAME="): |
| 45 | + USERNAME = line.split("=")[1].strip() |
| 46 | + elif line.startswith("PASSWORD="): |
| 47 | + PASSWORD = line.split("=")[1].strip() |
| 48 | + |
| 49 | +if not USERNAME or not PASSWORD: |
| 50 | + print("Username and password not present in .env file") |
| 51 | + exit(1) |
| 52 | + |
| 53 | +thermia = Thermia(USERNAME, PASSWORD) |
| 54 | + |
| 55 | +print("Connected: " + str(thermia.connected)) |
| 56 | + |
| 57 | +heat_pump = thermia.heat_pumps[0] |
| 58 | + |
| 59 | +print("Fetching debug data") |
| 60 | + |
| 61 | +debug_data = heat_pump.debug() |
| 62 | + |
| 63 | +print("Comparing debug data to existing debug file") |
| 64 | + |
| 65 | +absolute_path = os.path.dirname(os.path.abspath(__file__)) |
| 66 | +existing_data_filename = ( |
| 67 | + f"{absolute_path}/../ThermiaOnlineAPI/tests/debug_files/diplomat_duo_921.txt" |
| 68 | +) |
| 69 | + |
| 70 | +with open("debug.txt", "r") as f: |
| 71 | + existing_debug_data = f.read() |
| 72 | + |
| 73 | +for [existing_line, new_line] in zip( |
| 74 | + existing_debug_data.split("\n"), debug_data.split("\n") |
| 75 | +): |
| 76 | + if test_excluded_string_in_line(existing_line) and test_excluded_string_in_line( |
| 77 | + new_line |
| 78 | + ): |
| 79 | + continue |
| 80 | + |
| 81 | + if existing_line != new_line: |
| 82 | + print("Existing data does not match new data") |
| 83 | + print("Existing line: " + existing_line) |
| 84 | + print("New line: " + new_line) |
| 85 | + print("\n") |
| 86 | + exit(1) |
| 87 | + |
| 88 | +print("Debug data matches existing debug file") |
0 commit comments