From 5d9ed6db73f243b0ed3153b8da77214ddfe453d3 Mon Sep 17 00:00:00 2001 From: Krisjanis Lejejs Date: Fri, 9 Aug 2024 14:06:02 +0300 Subject: [PATCH] Add model id value to heat pump model --- ThermiaOnlineAPI/model/HeatPump.py | 58 ++++++++++++++++-------------- example.py | 4 +++ 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/ThermiaOnlineAPI/model/HeatPump.py b/ThermiaOnlineAPI/model/HeatPump.py index e3abf0a..a7b9ef4 100644 --- a/ThermiaOnlineAPI/model/HeatPump.py +++ b/ThermiaOnlineAPI/model/HeatPump.py @@ -144,9 +144,9 @@ 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() @@ -154,9 +154,9 @@ 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() @@ -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() @@ -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() @@ -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 @@ -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", []) @@ -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 @@ -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(), ) @@ -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") diff --git a/example.py b/example.py index 97f39e6..d273e78 100644 --- a/example.py +++ b/example.py @@ -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")