Skip to content

Commit

Permalink
Add model id value to heat pump model
Browse files Browse the repository at this point in the history
  • Loading branch information
klejejs committed Aug 9, 2024
1 parent f5ee654 commit 5d9ed6d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
58 changes: 31 additions & 27 deletions ThermiaOnlineAPI/model/HeatPump.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,19 @@ def set_temperature(self, temperature: int):

self._LOGGER.info("Setting temperature to " + str(temperature))

self.__status[
"heatingEffect"
] = temperature # update local state before refetching data
self.__status["heatingEffect"] = (
temperature # update local state before refetching data
)
self.__api_interface.set_temperature(self, temperature)
self.update_data()

def set_operation_mode(self, mode: str):
self._LOGGER.info("Setting operation mode to " + str(mode))

if self.__group_operational_operation is not None:
self.__group_operational_operation[
"current"
] = mode # update local state before refetching data
self.__group_operational_operation["current"] = (
mode # update local state before refetching data
)
self.__api_interface.set_operation_mode(self, mode)
self.update_data()

Expand All @@ -167,9 +167,9 @@ def set_hot_water_switch_state(self, state: int):
self._LOGGER.error("Hot water switch not available")
return

self.__group_hot_water[
"hot_water_switch"
] = state # update local state before refetching data
self.__group_hot_water["hot_water_switch"] = (
state # update local state before refetching data
)
self.__api_interface.set_hot_water_switch_state(self, state)
self.update_data()

Expand All @@ -180,9 +180,9 @@ def set_hot_water_boost_switch_state(self, state: int):
self._LOGGER.error("Hot water switch not available")
return

self.__group_hot_water[
"hot_water_boost_switch"
] = state # update local state before refetching data
self.__group_hot_water["hot_water_boost_switch"] = (
state # update local state before refetching data
)
self.__api_interface.set_hot_water_boost_switch_state(self, state)
self.update_data()

Expand Down Expand Up @@ -381,12 +381,12 @@ def __get_operational_statuses_from_operational_status(self) -> Optional[Dict]:
# 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.__device_config[
"operational_status_register"
] = REG_OPERATIONAL_STATUS_PRIO1
self.__device_config[
"operational_status_valueNamePrefix"
] = "REG_VALUE_STATUS_"
self.__device_config["operational_status_register"] = (
REG_OPERATIONAL_STATUS_PRIO1
)
self.__device_config["operational_status_valueNamePrefix"] = (
"REG_VALUE_STATUS_"
)
return data.get("valueNames", [])

# Try to get the data from the COMP_STATUS_ITEC register
Expand All @@ -401,9 +401,9 @@ def __get_operational_statuses_from_operational_status(self) -> Optional[Dict]:
REG_OPERATIONAL_STATUS_PRIORITY_BITMASK
)
if data is not None:
self.__device_config[
"operational_status_register"
] = REG_OPERATIONAL_STATUS_PRIORITY_BITMASK
self.__device_config["operational_status_register"] = (
REG_OPERATIONAL_STATUS_PRIORITY_BITMASK
)
self.__device_config["operational_status_valueNamePrefix"] = "REG_VALUE_"
return data.get("valueNames", [])

Expand All @@ -412,9 +412,9 @@ def __get_operational_statuses_from_operational_status(self) -> Optional[Dict]:
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_minRegisterValue"
] = "4" # 4 is OFF
self.__device_config["operational_status_minRegisterValue"] = (
"4" # 4 is OFF
)
return data.get("valueNames", [])

return None
Expand Down Expand Up @@ -451,9 +451,9 @@ def __get_all_visible_operational_statuses_from_operational_status(
return ChainMap()

operation_modes_map = map(
lambda item: {item[0]: item[1].get("name")}
if item[1].get("visible")
else {},
lambda item: (
{item[0]: item[1].get("name")} if item[1].get("visible") else {}
),
data.items(),
)

Expand Down Expand Up @@ -538,6 +538,10 @@ def model(self):
"thermiaName"
)

@property
def model_id(self):
return get_dict_value_or_default(self.__device_data, "profile", {}).get("name")

@property
def has_indoor_temp_sensor(self):
return get_dict_value_or_none(self.__status, "hasIndoorTempSensor")
Expand Down
4 changes: 4 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
heat_pump.debug()

print("\n")
print("\n")

print("Heat pump model: " + str(heat_pump.model))
print("Heat pump model id: " + str(heat_pump.model_id))

print("\n")

Expand Down

0 comments on commit 5d9ed6d

Please sign in to comment.