Skip to content

Commit 1b9fa92

Browse files
committed
add version check for breaking function
1 parent 133dd3b commit 1b9fa92

File tree

1 file changed

+7
-1
lines changed
  • custom_components/victron

1 file changed

+7
-1
lines changed

custom_components/victron/hub.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import logging
55
import threading
66

7+
from packaging import version
8+
import pymodbus
79
from pymodbus.client import ModbusTcpClient
810

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

3840
def convert_string_from_register(self, segment, string_encoding="ascii"):
3941
"""Convert from registers to the appropriate data type."""
42+
if version.parse("3.8.0") <= version.parse(pymodbus.__version__) <= version.parse("3.8.4"):
43+
return self._client.convert_from_registers(
44+
segment, self._client.DATATYPE.STRING
45+
).split("\x00")[0]
4046
return self._client.convert_from_registers(
41-
segment, self._client.DATATYPE.STRING, string_encoding="ascii"
47+
segment, self._client.DATATYPE.STRING, string_encoding=string_encoding
4248
).split("\x00")[0]
4349

4450
def convert_number_from_register(self, segment, dataType):

0 commit comments

Comments
 (0)