File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
custom_components/victron Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 44import logging
55import threading
66
7+ from packaging import version
8+ import pymodbus
79from pymodbus .client import ModbusTcpClient
810
911from 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 ):
You can’t perform that action at this time.
0 commit comments