Skip to content

Commit

Permalink
Fix current operation mode property
Browse files Browse the repository at this point in the history
  • Loading branch information
klejejs committed Jan 4, 2023
1 parent b46a8ff commit 90cab07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ThermiaOnlineAPI/model/HeatPump.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(self, device_data: dict, api_interface: "ThermiaAPI"):
# GROUPS
self.__group_temperatures = None
self.__group_operational_status = None
self.__operational_status_register = None
self.__group_operational_time = None
self.__group_operational_operation = None
self.__group_hot_water: Dict[str, Optional[int]] = {
Expand Down Expand Up @@ -344,9 +345,15 @@ def __get_value_by_key_and_register_name_from_operational_status(
return None

def __get_operational_statuses_from_operational_status(self) -> Optional[Dict]:
if self.__operational_status_register is not None:
return self.__get_register_from_operational_status(
self.__operational_status_register
)

# Try to get the data from the REG_OPERATIONAL_STATUS_PRIO1 register
data = self.__get_register_from_operational_status(REG_OPERATIONAL_STATUS_PRIO1)
if data is not None:
self.__operational_status_register = REG_OPERATIONAL_STATUS_PRIO1
return {
"registerValues": data.get("valueNames", []),
"valueNamePrefix": "REG_VALUE_STATUS_",
Expand All @@ -355,6 +362,7 @@ def __get_operational_statuses_from_operational_status(self) -> Optional[Dict]:
# Try to get the data from the COMP_STATUS_ITEC register
data = self.__get_register_from_operational_status(COMP_STATUS_ITEC)
if data is not None:
self.__operational_status_register = COMP_STATUS_ITEC
return {
"registerValues": data.get("valueNames", []),
"valueNamePrefix": "COMP_VALUE_",
Expand All @@ -365,6 +373,7 @@ def __get_operational_statuses_from_operational_status(self) -> Optional[Dict]:
REG_OPERATIONAL_STATUS_PRIORITY_BITMASK
)
if data is not None:
self.__operational_status_register = REG_OPERATIONAL_STATUS_PRIORITY_BITMASK
return {
"registerValues": data.get("valueNames", []),
"valueNamePrefix": "REG_VALUE_STATUS_",
Expand Down Expand Up @@ -546,7 +555,15 @@ def cooling_supply_line_temperature(self):

@property
def operational_status(self):
data = self.__get_register_from_operational_status(REG_OPERATIONAL_STATUS_PRIO1)
if self.__operational_status_register is None:
# Attempt to get the register from the status data
self.__get_operational_statuses_from_operational_status()
if self.__operational_status_register is None:
return None

data = self.__get_register_from_operational_status(
self.__operational_status_register
)

if data is None:
return None
Expand Down
1 change: 1 addition & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
print("Hot water status: " + str(heat_pump.operational_status_hot_water_status))
print("Heating status: " + str(heat_pump.operational_status_heating_status))
print("Integral: " + str(heat_pump.operational_status_integral))
print("Pid: " + str(heat_pump.operational_status_pid))

print("\n")

Expand Down

0 comments on commit 90cab07

Please sign in to comment.