From 236879412b3e163937a40bb91e83ad090107465c Mon Sep 17 00:00:00 2001 From: Dave Code <34915602+dave-code-ruiz@users.noreply.github.com> Date: Fri, 12 Jul 2024 10:21:13 +0200 Subject: [PATCH] Add files via upload --- .../uhomeuponor/uponor_api/__init__.py | 18 +-- .../uhomeuponor/uponor_api/const.py | 134 +++++++++--------- 2 files changed, 77 insertions(+), 75 deletions(-) diff --git a/custom_components/uhomeuponor/uponor_api/__init__.py b/custom_components/uhomeuponor/uponor_api/__init__.py index eef8e11..0783e09 100644 --- a/custom_components/uhomeuponor/uponor_api/__init__.py +++ b/custom_components/uhomeuponor/uponor_api/__init__.py @@ -165,7 +165,7 @@ async def update_values(self, allvalue_dict, *values): req = self.create_request("read") for value in values: - obj = {'id': str(value.id), 'properties': {'85': {}}} + obj = {'id': str(value.id), 'properties': {str(value.property): {}}} self.add_request_object(req, obj) response_data = await self.do_rest_call(req) @@ -174,11 +174,11 @@ async def update_values(self, allvalue_dict, *values): for obj in response_data['result']['objects']: try: data_id = int(obj['id']) - data_val = obj['properties']['85']['value'] + value = value_dict[data_id] + data_val = obj['properties'][value.property]['value'] except Exception as e: continue - value = value_dict[data_id] value.value = data_val def getStepValue(self, id, therm): @@ -220,7 +220,8 @@ def validate_values(self,response_data,allvalue_dict): for obj in response_data['result']['objects']: try: data_id = int(obj['id']) - data_val = obj['properties']['85']['value'] + value = allvalue_dict[data_id] + data_val = obj['properties'][value.property]['value'] step=self.getStepValue(data_id,therm) #only is necesary validate values in addrs 11,25,28, rest of values do not change if step != 0: @@ -246,7 +247,7 @@ def validate_values(self,response_data,allvalue_dict): #_LOGGER.debug("Response values, id %d, value %s, samevalue %d, old %s, idnext %s, next %s",data_id,data_val,samevalue,oldvalue.value,data_id+step,nextvalue.value) except Exception as e: - if '85' not in str(e): + if '85' not in str(e) and '662' not in str(e): _LOGGER.debug("Response error %s obj %s",e,obj) continue @@ -265,7 +266,7 @@ async def set_values(self, *value_tuples): req = self.create_request("write") for tpl in value_tuples: - obj = {'id': str(tpl[0].id), 'properties': {'85': {'value': str(tpl[1])}}} + obj = {'id': str(tpl[0].id), 'properties': {str(tpl[0].property): {'value': str(tpl[1])}}} self.add_request_object(req, obj) await self.do_rest_call(req) @@ -277,10 +278,11 @@ async def set_values(self, *value_tuples): class UponorValue(object): """Single value in the Uponor API""" - def __init__(self, id, name): + def __init__(self, id, name, prop): self.id = id self.name = name self.value = 0 + self.property = prop class UponorBaseDevice(ABC): """Base device class""" @@ -295,7 +297,7 @@ def __init__(self, uponor_client, id_offset, properties, identity_string): self.identity_string = identity_string for key_name, key_data in properties.items(): - value = UponorValue(id_offset + key_data['addr'], key_name) + value = UponorValue(id_offset + key_data['addr'], key_name, key_data['property']) self.properties_byid[value.id] = value self.properties_byname[value.name] = value diff --git a/custom_components/uhomeuponor/uponor_api/const.py b/custom_components/uhomeuponor/uponor_api/const.py index dca135d..43fbc80 100644 --- a/custom_components/uhomeuponor/uponor_api/const.py +++ b/custom_components/uhomeuponor/uponor_api/const.py @@ -15,81 +15,81 @@ # U@Home # Offset: 0 UHOME_MODULE_KEYS = { - 'module_id': {'addr': 20, 'value': 0}, - 'cooling_available': {'addr': 21, 'value': 0}, - 'holiday_mode': {'addr': 22, 'value': 0}, - 'forced_eco_mode': {'addr': 23, 'value': 0}, - 'hc_mode': {'addr': 24, 'value': 0}, - 'hc_masterslave': {'addr': 25, 'value': 0}, - 'ts_sv_version': {'addr': 26, 'value': 0}, - 'holiday_setpoint': {'addr': 27, 'value': 0}, - 'average_temp_low': {'addr': 28, 'value': 0}, - 'low_temp_alarm_limit': {'addr': 29, 'value': 0}, - 'low_temp_alarm_hysteresis': {'addr': 30, 'value': 0}, - 'remote_access_alarm': {'addr': 31, 'value': 0}, - 'device_lost_alarm': {'addr': 32, 'value': 0}, - 'no_comm_controller1': {'addr': 33, 'value': 0}, - 'no_comm_controller2': {'addr': 34, 'value': 0}, - 'no_comm_controller3': {'addr': 35, 'value': 0}, - 'no_comm_controller4': {'addr': 36, 'value': 0}, - 'average_room_temperature': {'addr': 37, 'value': 0}, - 'controller_presence': {'addr': 38, 'value': 0}, - 'allow_hc_mode_change': {'addr': 39, 'value': 0}, - 'hc_master_type': {'addr': 40, 'value': 0}, + 'module_id': {'addr': 20, 'value': 0, 'property': '85'}, + 'cooling_available': {'addr': 21, 'value': 0, 'property': '85'}, + 'holiday_mode': {'addr': 22, 'value': 0, 'property': '85'}, + 'forced_eco_mode': {'addr': 23, 'value': 0, 'property': '85'}, + 'hc_mode': {'addr': 24, 'value': 0, 'property': '85'}, + 'hc_masterslave': {'addr': 25, 'value': 0, 'property': '85'}, + 'ts_sv_version': {'addr': 26, 'value': 0, 'property': '85'}, + 'holiday_setpoint': {'addr': 27, 'value': 0, 'property': '85'}, + 'average_temp_low': {'addr': 28, 'value': 0, 'property': '85'}, + 'low_temp_alarm_limit': {'addr': 29, 'value': 0, 'property': '85'}, + 'low_temp_alarm_hysteresis': {'addr': 30, 'value': 0, 'property': '85'}, + 'remote_access_alarm': {'addr': 31, 'value': 0, 'property': '85'}, + 'device_lost_alarm': {'addr': 32, 'value': 0, 'property': '85'}, + 'no_comm_controller1': {'addr': 33, 'value': 0, 'property': '85'}, + 'no_comm_controller2': {'addr': 34, 'value': 0, 'property': '85'}, + 'no_comm_controller3': {'addr': 35, 'value': 0, 'property': '85'}, + 'no_comm_controller4': {'addr': 36, 'value': 0, 'property': '85'}, + 'average_room_temperature': {'addr': 37, 'value': 0, 'property': '85'}, + 'controller_presence': {'addr': 38, 'value': 0, 'property': '85'}, + 'allow_hc_mode_change': {'addr': 39, 'value': 0, 'property': '85'}, + 'hc_master_type': {'addr': 40, 'value': 0, 'property': '85'}, } # Controllers # Offset: 60 + 500 x c UHOME_CONTROLLER_KEYS = { - 'output_module': {'addr': 0, 'value': 0}, - 'rh_deadzone': {'addr': 1, 'value': 0}, - 'controller_sv_version': {'addr': 2, 'value': 0}, - 'thermostat_presence': {'addr': 3, 'value': 0}, - 'supply_high_alarm': {'addr': 4, 'value': 0}, - 'supply_low_alarm': {'addr': 5, 'value': 0}, - 'average_room_temperature_NO': {'addr': 6, 'value': 0}, - 'measured_outdoor_temperature': {'addr': 7, 'value': 0}, - 'supply_temp': {'addr': 8, 'value': 0}, - 'dehumidifier_status': {'addr': 9, 'value': 0}, - 'outdoor_sensor_presence': {'addr': 10, 'value': 0}, + 'output_module': {'addr': 0, 'value': 0, 'property': '85'}, + 'rh_deadzone': {'addr': 1, 'value': 0, 'property': '85'}, + 'controller_sv_version': {'addr': 2, 'value': 0, 'property': '85'}, + 'thermostat_presence': {'addr': 3, 'value': 0, 'property': '85'}, + 'supply_high_alarm': {'addr': 4, 'value': 0, 'property': '85'}, + 'supply_low_alarm': {'addr': 5, 'value': 0, 'property': '85'}, + 'average_room_temperature_NO': {'addr': 6, 'value': 0, 'property': '85'}, + 'measured_outdoor_temperature': {'addr': 7, 'value': 0, 'property': '85'}, + 'supply_temp': {'addr': 8, 'value': 0, 'property': '85'}, + 'dehumidifier_status': {'addr': 9, 'value': 0, 'property': '85'}, + 'outdoor_sensor_presence': {'addr': 10, 'value': 0, 'property': '85'}, } # Thermostats # Offset: 80 + 500 x c + 40 x t UHOME_THERMOSTAT_KEYS = { - 'eco_profile_active_cf': {'addr': 0, 'value': 0}, - 'dehumidifier_control_activation': {'addr': 1, 'value': 0}, - 'rh_control_activation': {'addr': 2, 'value': 0}, - 'eco_profile_number': {'addr': 3, 'value': 0}, - 'setpoint_write_enable': {'addr': 4, 'value': 0}, - 'cooling_allowed': {'addr': 5, 'value': 0}, - 'rh_setpoint': {'addr': 6, 'value': 0}, - 'min_setpoint': {'addr': 7, 'value': 0}, - 'max_setpoint': {'addr': 8, 'value': 0}, - 'min_floor_temp': {'addr': 9, 'value': 0}, - 'max_floor_temp': {'addr': 10, 'value': 0}, - 'room_setpoint': {'addr': 11, 'value': 0}, - 'eco_offset': {'addr': 12, 'value': 0}, - 'eco_profile_active': {'addr': 13, 'value': 0}, - 'home_away_mode_status': {'addr': 14, 'value': 0}, - 'room_in_demand': {'addr': 15, 'value': 0}, - 'rh_limit_reached': {'addr': 16, 'value': 0}, - 'floor_limit_status': {'addr': 17, 'value': 0}, - 'technical_alarm': {'addr': 18, 'value': 0}, - 'tamper_indication': {'addr': 19, 'value': 0}, - 'rf_alarm': {'addr': 20, 'value': 0}, - 'battery_alarm': {'addr': 21, 'value': 0}, - 'rh_sensor': {'addr': 22, 'value': 0}, - 'thermostat_type': {'addr': 23, 'value': 0}, - 'regulation_mode': {'addr': 24, 'value': 0}, - 'room_temperature': {'addr': 25, 'value': 0}, - 'room_temperature_ext': {'addr': 26, 'value': 0}, - 'rh_value': {'addr': 27, 'value': 0}, - 'ch_linked_to_th': {'addr': 28, 'value': 0}, - 'room_name': {'addr': 29, 'value': 0}, - 'utilization_factor_24h': {'addr': 30, 'value': 0}, - 'utilization_factor_7d': {'addr': 31, 'value': 0}, - 'reg_mode': {'addr': 32, 'value': 0}, - 'channel_average': {'addr': 33, 'value': 0}, - 'radiator_heating': {'addr': 34, 'value': 0} + 'eco_profile_active_cf': {'addr': 0, 'value': 0, 'property': '85'}, + 'dehumidifier_control_activation': {'addr': 1, 'value': 0, 'property': '85'}, + 'rh_control_activation': {'addr': 2, 'value': 0, 'property': '85'}, + 'eco_profile_number': {'addr': 3, 'value': 0, 'property': '85'}, + 'setpoint_write_enable': {'addr': 4, 'value': 0, 'property': '85'}, + 'cooling_allowed': {'addr': 5, 'value': 0, 'property': '85'}, + 'rh_setpoint': {'addr': 6, 'value': 0, 'property': '85'}, + 'min_setpoint': {'addr': 7, 'value': 0, 'property': '85'}, + 'max_setpoint': {'addr': 8, 'value': 0, 'property': '85'}, + 'min_floor_temp': {'addr': 9, 'value': 0, 'property': '85'}, + 'max_floor_temp': {'addr': 10, 'value': 0, 'property': '85'}, + 'room_setpoint': {'addr': 11, 'value': 0, 'property': '85'}, + 'eco_offset': {'addr': 12, 'value': 0, 'property': '85'}, + 'eco_profile_active': {'addr': 13, 'value': 0, 'property': '85'}, + 'home_away_mode_status': {'addr': 14, 'value': 0, 'property': '85'}, + 'room_in_demand': {'addr': 15, 'value': 0, 'property': '85'}, + 'rh_limit_reached': {'addr': 16, 'value': 0, 'property': '85'}, + 'floor_limit_status': {'addr': 17, 'value': 0, 'property': '85'}, + 'technical_alarm': {'addr': 18, 'value': 0, 'property': '662'}, + 'tamper_indication': {'addr': 19, 'value': 0, 'property': '662'}, + 'rf_alarm': {'addr': 20, 'value': 0, 'property': '662'}, + 'battery_alarm': {'addr': 21, 'value': 0, 'property': '662'}, + 'rh_sensor': {'addr': 22, 'value': 0, 'property': '85'}, + 'thermostat_type': {'addr': 23, 'value': 0, 'property': '85'}, + 'regulation_mode': {'addr': 24, 'value': 0, 'property': '85'}, + 'room_temperature': {'addr': 25, 'value': 0, 'property': '85'}, + 'room_temperature_ext': {'addr': 26, 'value': 0, 'property': '85'}, + 'rh_value': {'addr': 27, 'value': 0, 'property': '85'}, + 'ch_linked_to_th': {'addr': 28, 'value': 0, 'property': '85'}, + 'room_name': {'addr': 29, 'value': 0, 'property': '85'}, + 'utilization_factor_24h': {'addr': 30, 'value': 0, 'property': '85'}, + 'utilization_factor_7d': {'addr': 31, 'value': 0, 'property': '85'}, + 'reg_mode': {'addr': 32, 'value': 0, 'property': '85'}, + 'channel_average': {'addr': 33, 'value': 0, 'property': '85'}, + 'radiator_heating': {'addr': 34, 'value': 0, 'property': '85'} }