Skip to content

Commit

Permalink
Update to handle U32 and S32 values
Browse files Browse the repository at this point in the history
  • Loading branch information
nliaudat authored Aug 8, 2024
1 parent 1ab146a commit bf4a630
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
37 changes: 21 additions & 16 deletions esphome/hoval_data_processing/generate_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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(
Expand All @@ -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')
Expand Down
17 changes: 11 additions & 6 deletions esphome/hoval_data_processing/xls_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bf4a630

Please sign in to comment.