COnvert DATA_TYPE to enum. (#57699)
This commit is contained in:
parent
faf5c2eb40
commit
4417ffb407
8 changed files with 122 additions and 155 deletions
|
@ -53,9 +53,9 @@ from .const import (
|
|||
CONF_SWAP_WORD_BYTE,
|
||||
CONF_VERIFY,
|
||||
CONF_WRITE_TYPE,
|
||||
DATA_TYPE_STRING,
|
||||
SIGNAL_START_ENTITY,
|
||||
SIGNAL_STOP_ENTITY,
|
||||
DataType,
|
||||
)
|
||||
from .modbus import ModbusHub
|
||||
|
||||
|
@ -165,7 +165,7 @@ class BaseStructPlatform(BasePlatform, RestoreEntity):
|
|||
|
||||
registers = self._swap_registers(registers)
|
||||
byte_string = b"".join([x.to_bytes(2, byteorder="big") for x in registers])
|
||||
if self._data_type == DATA_TYPE_STRING:
|
||||
if self._data_type == DataType.STRING:
|
||||
return byte_string.decode()
|
||||
|
||||
val = struct.unpack(self._structure, byte_string)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue