diff --git a/esphome/hoval_data_processing/generate_presets.py b/esphome/hoval_data_processing/generate_presets.py index eb137d7..30a9210 100644 --- a/esphome/hoval_data_processing/generate_presets.py +++ b/esphome/hoval_data_processing/generate_presets.py @@ -30,7 +30,8 @@ def generate(self, wb: Workbook, out_dir: pathlib.Path): for dp in datapoints: if dp.type_name in ["U32", "S32"]: - dp.name = re.sub(r'(_low|_high)$', "", dp.name) + dp.name = re.sub(r'( low| high)$', "", dp.name) # for HV + dp.name = re.sub(r'(_low|_high)$', "", dp.name) # for WEZ os.makedirs(out_dir.joinpath(self.id), exist_ok=True) @@ -103,20 +104,24 @@ def bd_before_dump(datapoints: list[Datapoint], locale: str): 1401, # hot water temp. 1437, # WEZ output ]), before_dump=wez_before_dump), - Preset('HV', Filter(rows=[ - 22705, # Outside air temp. - 22700, # Humidity extract air - 22706, # Extract air temp. - 22701, # VOC extract air - 22702, # VOC outdoor air - 22707, # Fan exhaust air set - 22698, # Ventilation modulation - # 22703, # Air quality control - 22704, # Status vent regulation - 22695, # Op. choice ventilation - 22696, # Normal ventilation modulation - 22697, # Eco ventilation modulation - 22699, # Humidity set value + ## filter the row number, not the datapoint : based on UniName=HV, UnitId=520 + Preset('HV', Filter(rows=[ + 22786, # Op. choice ventilation + 22787, # Normal ventilation modulation + 22788, # Eco ventilation modulation + 22789, # Ventilation modulation + 22790, # Humidity set value + 22791, # Humidity extract air + # 22792, # VOC extract air + # 22793, # VOC outdoor air + # 22794, # Air quality control + 22795, # Status vent regulation + 22796, # Outside air temp. + 22797, # Extract air temp. + 22798, # Fan exhaust air set + 28099, # Maint.ctr.value message maint. (op. wks) + 28101, # Rem. run time maint. counter (op. weeks) + 28110, # Cleaning count value message cleaning (operating weeks) ]), hv_before_translate), Preset('BM', [ Datapoint( @@ -141,7 +146,7 @@ def bd_before_dump(datapoints: list[Datapoint], locale: str): parser = argparse.ArgumentParser( prog='Generate Presets', - description='Genertes sensors and inputs for Hoval devices', + description='Generates sensors and inputs for Hoval devices', ) parser.add_argument('out_dir') diff --git a/esphome/hoval_data_processing/xls_parser.py b/esphome/hoval_data_processing/xls_parser.py index 77be5e2..a0c3ef6 100644 --- a/esphome/hoval_data_processing/xls_parser.py +++ b/esphome/hoval_data_processing/xls_parser.py @@ -42,19 +42,24 @@ def __toptronic_base(self) -> dict: def into_sensor(self) -> dict: assert self.type_name != 'LIST' - deciamls = { - 'accuracy_decimals': self.decimal, + try: + decimal_value = int(self.decimal) + except (ValueError, TypeError): + decimal_value = 0 # Default value or handle it as you see fit + + decimals = { + 'accuracy_decimals': decimal_value, 'filters': [{ - 'multiply': pow(10, -self.decimal) + 'multiply': pow(10, -decimal_value) }] - } if self.decimal > 0 else {} + } if decimal_value > 0 else {} return { **self.__toptronic_base(), 'id': self.get_id(), 'type': self.type_name, - 'unit_of_measurement': self.unit, - **deciamls, + 'unit_of_measurement': self.unit if self.unit is not None else '', + **decimals, } def into_text_sensor(self) -> dict: