Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport 2025.2 from remcom fork #278

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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