Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sfstar committed Mar 7, 2025
1 parent 3782b5a commit 4338679
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions custom_components/victron/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ async def fetch_registers(self, unit, registerData):
"""Fetch the registers."""
try:
# run api_update in async job
return await self.api_update(unit, registerData)
return await self.api.read_holding_registers(
unit=unit,
address=self.api.get_first_register_id(registerData),
count=self.api.calculate_register_count(registerData),
)

except HomeAssistantError as e:
raise UpdateFailed("Fetching registers failed") from e
Expand All @@ -203,15 +207,6 @@ def write_register(self, unit, address, value):
# recycle connection
return self.api.write_register(unit=unit, address=address, value=value)

async def api_update(self, unit, registerInfo):
"""Update the api."""
# recycle connection
return await self.api.read_holding_registers(
unit=unit,
address=self.api.get_first_register_id(registerInfo),
count=self.api.calculate_register_count(registerInfo),
)


class DecodeDataTypeUnsupported(Exception):
"""Exception for unsupported data type."""
Expand Down

0 comments on commit 4338679

Please sign in to comment.