Skip to content

Commit

Permalink
Add support for read only operation modes from status
Browse files Browse the repository at this point in the history
  • Loading branch information
klejejs committed Oct 13, 2024
1 parent 59b6c0a commit 82b85e4
Show file tree
Hide file tree
Showing 5 changed files with 1,072 additions and 17 deletions.
14 changes: 12 additions & 2 deletions ThermiaOnlineAPI/api/ThermiaAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,20 @@ def get__group_operational_time(self, device_id: str):
return self.__get_register_group(device_id, REG_GROUP_OPERATIONAL_TIME)

def get_group_operational_operation(self, device: ThermiaHeatPump):
register_data = self.__get_register_group(
device.id, REG_GROUP_OPERATIONAL_OPERATION
return self.__get_group_operational_operation_from_register_group(
device, REG_GROUP_OPERATIONAL_OPERATION
)

def get_group_operational_operation_from_status(self, device: ThermiaHeatPump):
return self.__get_group_operational_operation_from_register_group(
device, REG_GROUP_OPERATIONAL_STATUS
)

def __get_group_operational_operation_from_register_group(
self, device: ThermiaHeatPump, register_group: str
):
register_data = self.__get_register_group(device.id, register_group)

data = [d for d in register_data if d["registerName"] == REG_OPERATIONMODE]

if len(data) != 1:
Expand Down
37 changes: 33 additions & 4 deletions ThermiaOnlineAPI/model/HeatPump.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self, device_data: dict, api_interface: "ThermiaAPI"):
self.__group_operational_status = None
self.__group_operational_time = None
self.__group_operational_operation = None
self.__group_operational_operation_read_only = None
self.__group_hot_water: Dict[str, Optional[int]] = {
"hot_water_switch": None,
"hot_water_boost_switch": None,
Expand Down Expand Up @@ -116,6 +117,9 @@ def update_data(self):
self.__group_operational_operation = (
self.__api_interface.get_group_operational_operation(self)
)
self.__group_operational_operation_read_only = (
self.__api_interface.get_group_operational_operation_from_status(self)
)
self.__group_hot_water = self.__api_interface.get_group_hot_water(self)

self.__alarms = self.__api_interface.get_all_alarms(self.__device_id)
Expand Down Expand Up @@ -892,25 +896,50 @@ def auxiliary_heater_3_operational_time(self):

@property
def operation_mode(self):
return get_dict_value_or_none(self.__group_operational_operation, "current")
if self.__group_operational_operation is not None:
return get_dict_value_or_none(self.__group_operational_operation, "current")

return get_dict_value_or_none(
self.__group_operational_operation_read_only, "current"
)

@property
def available_operation_modes(self):
if self.__group_operational_operation is not None:
return list(
get_dict_value_or_default(
self.__group_operational_operation, "available", {}
).values()
)

return list(
get_dict_value_or_default(
self.__group_operational_operation, "available", {}
self.__group_operational_operation_read_only, "available", {}
).values()
)

@property
def available_operation_mode_map(self):
if self.__group_operational_operation is not None:
return get_dict_value_or_default(
self.__group_operational_operation, "available", {}
)

return get_dict_value_or_default(
self.__group_operational_operation, "available", {}
self.__group_operational_operation_read_only, "available", {}
)

@property
def is_operation_mode_read_only(self):
return get_dict_value_or_none(self.__group_operational_operation, "isReadOnly")
if self.__group_operational_operation is not None:
return get_dict_value_or_none(
self.__group_operational_operation, "isReadOnly"
)

if self.__group_operational_operation_read_only is not None:
True

return None

###########################################################################
# Hot water data
Expand Down
Loading

0 comments on commit 82b85e4

Please sign in to comment.