Skip to content

Commit

Permalink
feat: Add profile redirect table for renamed files
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Aug 16, 2024
1 parent b1e6cce commit cabeab0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/solarman/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions custom_components/solarman/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions custom_components/solarman/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit cabeab0

Please sign in to comment.