diff --git a/custom_components/solarman/api.py b/custom_components/solarman/api.py index 97d06ba..16d3c65 100644 --- a/custom_components/solarman/api.py +++ b/custom_components/solarman/api.py @@ -74,7 +74,7 @@ async def load(self, name, mac, path, file): self.name = name self.mac = mac self.lookup_path = path - self.lookup_file = file if file else "deye_hybrid.yaml" + self.lookup_file = process_profile(file if file else "deye_hybrid.yaml") self.model = self.lookup_file.replace(".yaml", "") self.parameter_definition = await yaml_open(self.lookup_path + self.lookup_file) self.profile = ParameterParser(self.parameter_definition) diff --git a/custom_components/solarman/common.py b/custom_components/solarman/common.py index 529d120..6be6198 100644 --- a/custom_components/solarman/common.py +++ b/custom_components/solarman/common.py @@ -26,6 +26,9 @@ async def yaml_open(file): async with aiofiles.open(file) as f: return yaml.safe_load(await f.read()) +def process_profile(filename): + return filename if not filename in PROFILE_REDIRECT_TABLE else PROFILE_REDIRECT_TABLE[filename] + def is_platform(description, value): return (description["platform"] if "platform" in description else "sensor") == value diff --git a/custom_components/solarman/const.py b/custom_components/solarman/const.py index fbe984d..30d6214 100644 --- a/custom_components/solarman/const.py +++ b/custom_components/solarman/const.py @@ -43,6 +43,8 @@ DEFAULT_REGISTERS_MIN_SPAN = 25 DEFAULT_DIGITS = 6 +PROFILE_REDIRECT_TABLE = { "sofar_hyd3k-6k-es.yaml": "sofar_hyd-es.yaml", "hyd-zss-hp-3k-6k.yaml": "zcs_azzurro-hyd-zss-hp.yaml" } + AUTO_RECONNECT = True # Data are requsted in most cases in different invervals: