Skip to content
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/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import logging
import threading

from packaging import version
import pymodbus
from pymodbus.client import ModbusTcpClient

from homeassistant.exceptions import HomeAssistantError
Expand Down Expand Up @@ -37,8 +39,12 @@ def is_still_connected(self):

def convert_string_from_register(self, segment, string_encoding="ascii"):
"""Convert from registers to the appropriate data type."""
if version.parse("3.8.0") <= version.parse(pymodbus.__version__) <= version.parse("3.8.4"):
return self._client.convert_from_registers(
segment, self._client.DATATYPE.STRING
).split("\x00")[0]
return self._client.convert_from_registers(
segment, self._client.DATATYPE.STRING, string_encoding="ascii"
segment, self._client.DATATYPE.STRING, string_encoding=string_encoding
).split("\x00")[0]

def convert_number_from_register(self, segment, dataType):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/victron/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/sfstar/hass-victron/issues",
"requirements": [
"pymodbus>=3.7.4"
"pymodbus>=3.8.0"
],
"ssdp": [],
"version": "v0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"zip_release": true,
"filename": "victron.zip",
"hide_default_branch": false,
"homeassistant": "2025.1",
"homeassistant": "2025.2",
"hacs": "1.28.4"
}
Loading