Skip to content

Commit 0c729d5

Browse files
committed
Add debug messages for obsolete entry names
1 parent 9b41c77 commit 0c729d5

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

luxtronik/calculations.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,17 @@ def __init__(self):
318318
}
319319

320320
def get_firmware_version(self):
321+
"""Get the firmware version as string."""
321322
return "".join([super(Calculations, self).get(i).value for i in range(81, 91)])
322323

323324
def _get_firmware_version(self):
325+
"""Get the firmware version as string like in previous versions."""
324326
return self.get_firmware_version().strip("\x00")
325327

326328
def get(self, target):
329+
"""Treats certain names specially. For all others, the function of the base class is called."""
327330
if target == "ID_WEB_SoftStand":
331+
self.logger.debug(f"The name 'ID_WEB_SoftStand' is obsolete! Use 'get_firmware_version()' instead.")
328332
entry = Base("ID_WEB_SoftStand")
329333
entry.raw = self._get_firmware_version()
330334
return entry

luxtronik/data_vector.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ def _lookup(self, target, with_index=False):
4747
# Get entry by name
4848
target_index = None
4949
for index, entry in self._data.items():
50-
if target in entry.get_supported_names():
50+
check_result = entry.check_name(target)
51+
if check_result in ["preferred", "obsolete"]:
5152
target_index = index
53+
if check_result == "obsolete":
54+
self.logger.debug(f"The name '{target}' is obsolete! Use '{entry.name}' instead.")
5255
elif isinstance(target, int):
5356
# Get entry by id
5457
target_index = target

luxtronik/datatypes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ def get_supported_names(self):
4747
else:
4848
return [self._name]
4949

50+
def check_name(self, name):
51+
"""
52+
Check whether a name matches one of the supported entry names.
53+
The result string can be used to trigger a debug message for obsolete names.
54+
"""
55+
if name == self.name:
56+
return "preferred"
57+
elif name in self.get_supported_names():
58+
return "obsolete"
59+
else:
60+
return "none"
61+
5062
@property
5163
def value(self):
5264
"""Return the stored value converted from heatpump units."""

0 commit comments

Comments
 (0)