Skip to content

Commit

Permalink
attempt to handle unknown parameters automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouni committed Jun 7, 2022
1 parent 92ac225 commit 850daa4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
8 changes: 7 additions & 1 deletion luxtronik/calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,22 @@ def parse(self, raw_data):
"""Parse raw calculations data."""
for index, data in enumerate(raw_data):
calculation = self.calculations.get(index, False)
# index is not version info (index 81 up to 91), proceed normally
if calculation is not False and index not in range(81, 91):
calculation.value = calculation.from_heatpump(data)
continue
# index is version info, parse entire range from 81 up to 91 as version string
if calculation is not False and index in range(81, 91):
calculation.value = calculation.from_heatpump(
raw_data[index : index + 9]
)
continue
# index is outside the known range, create it as unknown
if calculation is False and index not in range(81, 91):
LOGGER.warning("Calculation '%d' not in list of calculationss", index)
#LOGGER.warning("Calculation '%d' not in list of calculationss", index)
calculation = Unknown(f"Unknown_Calculation_{index}")
calculation.value = calculation.from_heatpump(data)
self.calculations[index] = calculation

def _lookup(self, target):
"""Lookup calculation by either id or name."""
Expand Down
5 changes: 4 additions & 1 deletion luxtronik/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,10 @@ def parse(self, raw_data):
if parameter is not False:
parameter.value = parameter.from_heatpump(data)
else:
LOGGER.warning("Parameter '%d' not in list of parameters", index)
#LOGGER.warning("Parameter '%d' not in list of parameters", index)
parameter = Unknown(f"Unknown_Parameter_{index}")
parameter.value = parameter.from_heatpump(data)
self.parameters[index] = parameter

def _lookup(self, target, with_index=False):
"""Lookup parameter by either id or name."""
Expand Down
5 changes: 4 additions & 1 deletion luxtronik/visibilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,10 @@ def parse(self, raw_data):
if visibility is not False:
visibility.value = visibility.from_heatpump(data)
else:
LOGGER.warning("Visibility '%d' not in list of visibilities", index)
#LOGGER.warning("Visibility '%d' not in list of visibilities", index)
visibility = Unknown(f"Unknown_Parameter_{index}")
visibility.value = visibility.from_heatpump(data)
self.visibilities[index] = visibility

def _lookup(self, target):
"""Lookup visibility by either id or name."""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="luxtronik",
version="0.3.13",
version="0.3.14",
author="Bouni",
author_email="[email protected]",
description="A luxtronik heatpump controller interface",
Expand Down

0 comments on commit 850daa4

Please sign in to comment.