Skip to content

Commit

Permalink
Merge pull request #278 from sfstar/feature/add_2025.2_support
Browse files Browse the repository at this point in the history
backport 2025.2 from remcom fork
  • Loading branch information
sfstar authored Jan 29, 2025
2 parents a4ce46e + 74a454e commit d1611f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 7 additions & 1 deletion custom_components/victron/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@

from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder
from pymodbus.pdu.register_read_message import ReadHoldingRegistersResponse

import pymodbus

if "3.7.0" <= pymodbus.__version__ <= "3.7.4":
from pymodbus.pdu.register_read_message import ReadHoldingRegistersResponse
else:
from pymodbus.pdu.register_message import ReadHoldingRegistersResponse

from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
Expand Down
12 changes: 6 additions & 6 deletions custom_components/victron/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ def disconnect(self):
return None

def write_register(self, unit, address, value):
with self._lock:
kwargs = {"slave": int(unit)} if unit else {}
return self._client.write_register(address, value, **kwargs)
slave = int(unit) if unit else 1
return self._client.write_register(address=address, value=value, slave=slave)

def read_holding_registers(self, unit, address, count):
"""Read holding registers."""
with self._lock:
kwargs = {"slave": int(unit)} if unit else {}
return self._client.read_holding_registers(address, count, **kwargs)
slave = int(unit) if unit else 1
return self._client.read_holding_registers(
address=address, count=count, slave=slave
)

def calculate_register_count(self, registerInfoDict: OrderedDict):
first_key = next(iter(registerInfoDict))
Expand Down

0 comments on commit d1611f3

Please # to comment.