Skip to content

Commit

Permalink
- added new types
Browse files Browse the repository at this point in the history
- fault-tolerant reading of types, fw, etc...
  • Loading branch information
marq24 committed May 26, 2024
1 parent 4017c3d commit 9b986bb
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 16 deletions.
2 changes: 1 addition & 1 deletion custom_components/waterkotte_heatpump/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/marq24/ha-waterkotte/issues",
"requirements": [],
"version": "2024.5.1"
"version": "2024.5.2"
}
34 changes: 32 additions & 2 deletions custom_components/waterkotte_heatpump/pywaterkotte_ha/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
4: "mode4",
5: "mode5"
}

SERIES: Final = [
"Custom",
"Ai1",
Expand Down Expand Up @@ -368,6 +367,22 @@
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
]
SYSTEM_IDS: Final = [
"Ai1 5005.4",
Expand Down Expand Up @@ -725,9 +740,24 @@
"ET 5144.4 Tandem",
"ET 5179.4 Tandem",
"ET 5222.4 Tandem",
"5004.5(1x230V)",
"5007.5(1x230V)",
"5009.5(1x230V)",
"5011.5(1x230V)",
"5004.5(1x230V)",
"5007.5(1x230V)",
"5009.5(1x230V)",
"5011.5(1x230V)",
"5004.5(1x230V)",
"5007.5(1x230V)",
"5009.5(1x230V)",
"5011.5(1x230V)",
"5004.5(1x230V)",
"5007.5(1x230V)",
"5009.5(1x230V)",
"5011.5(1x230V)",
None,
]

TRANSLATIONS: Final = {
"de": {
# states...
Expand Down
52 changes: 39 additions & 13 deletions custom_components/waterkotte_heatpump/pywaterkotte_ha/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
import math
import struct
from datetime import datetime, timedelta, time

from enum import Enum
# from aenum import Enum, extend_enum

from typing import (
NamedTuple,
Callable,
Expand All @@ -20,11 +17,12 @@
# SCHEDULE_DAY_LIST,
# SCHEDULE_SENSOR_TYPES_LIST
)

from custom_components.waterkotte_heatpump.pywaterkotte_ha.error import (
InvalidValueException,
)

# from aenum import Enum, extend_enum

_LOGGER: logging.Logger = logging.getLogger(__package__)


Expand Down Expand Up @@ -273,32 +271,60 @@ def _encode_status(self, value, encoded_values):
encoded_values[ecotouch_tag] = "2"

def _decode_ro_series(self, str_vals: List[str]):
return SERIES[int(str_vals[0])] if str_vals[0] else ""
if str_vals[0]:
if isinstance(str_vals[0], int):
idx = int(str_vals[0])
if len(SERIES) > idx:
return SERIES[idx]
else:
return f"UNKNOWN_SERIES_{idx}"
else:
return "UNKNOWN_SERIES"

def _decode_ro_id(self, str_vals: List[str]):
assert len(self.tags) == 1
return SYSTEM_IDS[int(str_vals[0])] if str_vals[0] else ""
if str_vals[0]:
if isinstance(str_vals[0], int):
idx = int(str_vals[0])
if len(SYSTEM_IDS) > idx:
return SYSTEM_IDS[idx]
else:
return f"UNKNOWN_SYSTEM_{idx}"
else:
return "UNKNOWN_SYSTEM"


def _decode_ro_bios(self, str_vals: List[str]):
assert len(self.tags) == 1
str_val = str_vals[0]
return f"{str_val[:-2]}.{str_val[-2:]}"
if len(str_val) > 2:
return f"{str_val[:-2]}.{str_val[-2:]}"
else:
return str_val

def _decode_ro_fw(self, str_vals: List[str]):
assert len(self.tags) == 2
str_val1 = str_vals[0]
str_val2 = str_vals[1]
# str fw2 = f"{str_val1[:-4]:0>2}.{str_val1[-4:-2]}.{str_val1[-2:]}"
return f"0{str_val1[0]}.{str_val1[1:3]}.{str_val1[3:]}-{str_val2}"
try:
# str fw2 = f"{str_val1[:-4]:0>2}.{str_val1[-4:-2]}.{str_val1[-2:]}"
return f"0{str_val1[0]}.{str_val1[1:3]}.{str_val1[3:]}-{str_val2}"
except Exception as ex:
_LOGGER.warning("could not decode FW",ex)
return f"FW_{str_val1}-{str_val2}"

def _decode_ro_sn(self, str_vals: List[str]):
assert len(self.tags) == 2
sn1 = int(str_vals[0])
sn2 = int(str_vals[1])
s1 = "WE" if math.floor(sn1 / 1000) > 0 else "00" # pylint: disable=invalid-name
s2 = (sn1 - 1000 if math.floor(sn1 / 1000) > 0 else sn1) # pylint: disable=invalid-name
s2 = "0" + str(s2) if s2 < 10 else s2 # pylint: disable=invalid-name
return str(s1) + str(s2) + str(sn2)
try:
s1 = "WE" if math.floor(sn1 / 1000) > 0 else "00" # pylint: disable=invalid-name
s2 = (sn1 - 1000 if math.floor(sn1 / 1000) > 0 else sn1) # pylint: disable=invalid-name
s2 = "0" + str(s2) if s2 < 10 else s2 # pylint: disable=invalid-name
return str(s1) + str(s2) + str(sn2)
except Exception as ex:
_LOGGER.warning("could not decode Serial",ex)
return f"Serial_{sn1}-{sn2}"

def _decode_year(self, str_vals: List[str]):
assert len(self.tags) == 1
Expand Down

0 comments on commit 9b986bb

Please sign in to comment.