Skip to content

Commit

Permalink
Merge pull request #16 from klejejs/fix/#15_operational-status-diplomat
Browse files Browse the repository at this point in the history
Fix operational status for Thermia Diplomat heat pumps
  • Loading branch information
klejejs authored Jan 19, 2023
2 parents 2f0ec4e + b321436 commit aa70344
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions ThermiaOnlineAPI/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
REG_OPERATIONAL_STATUS_PRIO1 = (
"REG_OPERATIONAL_STATUS_PRIO1" # Operational status for most heat pumps
)
COMP_STATUS = "COMP_STATUS" # Operational status for Diplomat heat pumps
COMP_STATUS_ITEC = "COMP_STATUS_ITEC" # Operational status for ITEC heat pumps
REG_OPERATIONAL_STATUS_PRIORITY_BITMASK = (
"REG_OPERATIONAL_STATUS_PRIORITY_BITMASK" # Operational status for Atlas heat pumps
Expand Down
19 changes: 17 additions & 2 deletions ThermiaOnlineAPI/model/HeatPump.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
REG_OPER_TIME_IMM3,
REG_PID,
REG_RETURN_LINE,
COMP_STATUS,
COMP_STATUS_ITEC,
REG_SUPPLY_LINE,
DATETIME_FORMAT,
Expand Down Expand Up @@ -59,6 +60,7 @@ def __init__(self, device_data: dict, api_interface: "ThermiaAPI"):
self.__device_config: Dict[str, Optional[str]] = {
"operational_status_register": None,
"operational_status_valueNamePrefix": None,
"operational_status_minRegisterValue": None,
}

# GROUPS
Expand Down Expand Up @@ -382,9 +384,17 @@ def __get_operational_statuses_from_operational_status(self) -> Optional[Dict]:
self.__device_config[
"operational_status_register"
] = REG_OPERATIONAL_STATUS_PRIORITY_BITMASK
self.__device_config["operational_status_valueNamePrefix"] = "REG_VALUE_"
return data.get("valueNames", [])

# Try to get the data from the COMP_STATUS register
data = self.__get_register_from_operational_status(COMP_STATUS)
if data is not None:
self.__device_config["operational_status_register"] = COMP_STATUS
self.__device_config["operational_status_valueNamePrefix"] = "COMP_VALUE_"
self.__device_config[
"operational_status_valueNamePrefix"
] = "REG_VALUE_"
"operational_status_minRegisterValue"
] = "4" # 4 is OFF
return data.get("valueNames", [])

return None
Expand Down Expand Up @@ -594,6 +604,11 @@ def operational_status(self) -> Optional[Union[str, List[str]]]:
data_items_list.sort(key=lambda x: x[0], reverse=True)
list_of_current_operation_modes = []

if self.__device_config["operational_status_minRegisterValue"] is not None:
current_register_value -= int(
self.__device_config["operational_status_minRegisterValue"]
)

for value, name in data_items_list:
if value <= current_register_value:
current_register_value -= value
Expand Down

0 comments on commit aa70344

Please sign in to comment.