mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Bump pymodbus version 3.7.4 (#133175)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
parent
85ef2c0fb1
commit
760c3ac98c
@ -121,7 +121,7 @@ class ModbusBinarySensor(BasePlatform, RestoreEntity, BinarySensorEntity):
|
||||
else:
|
||||
self._attr_available = True
|
||||
if self._input_type in (CALL_TYPE_COIL, CALL_TYPE_DISCRETE):
|
||||
self._result = result.bits
|
||||
self._result = [int(bit) for bit in result.bits]
|
||||
else:
|
||||
self._result = result.registers
|
||||
self._attr_is_on = bool(self._result[0] & 1)
|
||||
|
@ -5,5 +5,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/modbus",
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["pymodbus"],
|
||||
"requirements": ["pymodbus==3.6.9"]
|
||||
"requirements": ["pymodbus==3.7.4"]
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ from pymodbus.client import (
|
||||
AsyncModbusUdpClient,
|
||||
)
|
||||
from pymodbus.exceptions import ModbusException
|
||||
from pymodbus.pdu import ModbusResponse
|
||||
from pymodbus.transaction import ModbusAsciiFramer, ModbusRtuFramer, ModbusSocketFramer
|
||||
from pymodbus.framer import FramerType
|
||||
from pymodbus.pdu import ModbusPDU
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import (
|
||||
@ -265,14 +265,13 @@ class ModbusHub:
|
||||
"port": client_config[CONF_PORT],
|
||||
"timeout": client_config[CONF_TIMEOUT],
|
||||
"retries": 3,
|
||||
"retry_on_empty": True,
|
||||
}
|
||||
if self._config_type == SERIAL:
|
||||
# serial configuration
|
||||
if client_config[CONF_METHOD] == "ascii":
|
||||
self._pb_params["framer"] = ModbusAsciiFramer
|
||||
self._pb_params["framer"] = FramerType.ASCII
|
||||
else:
|
||||
self._pb_params["framer"] = ModbusRtuFramer
|
||||
self._pb_params["framer"] = FramerType.RTU
|
||||
self._pb_params.update(
|
||||
{
|
||||
"baudrate": client_config[CONF_BAUDRATE],
|
||||
@ -285,9 +284,9 @@ class ModbusHub:
|
||||
# network configuration
|
||||
self._pb_params["host"] = client_config[CONF_HOST]
|
||||
if self._config_type == RTUOVERTCP:
|
||||
self._pb_params["framer"] = ModbusRtuFramer
|
||||
self._pb_params["framer"] = FramerType.RTU
|
||||
else:
|
||||
self._pb_params["framer"] = ModbusSocketFramer
|
||||
self._pb_params["framer"] = FramerType.SOCKET
|
||||
|
||||
if CONF_MSG_WAIT in client_config:
|
||||
self._msg_wait = client_config[CONF_MSG_WAIT] / 1000
|
||||
@ -370,12 +369,12 @@ class ModbusHub:
|
||||
|
||||
async def low_level_pb_call(
|
||||
self, slave: int | None, address: int, value: int | list[int], use_call: str
|
||||
) -> ModbusResponse | None:
|
||||
) -> ModbusPDU | None:
|
||||
"""Call sync. pymodbus."""
|
||||
kwargs = {"slave": slave} if slave else {}
|
||||
entry = self._pb_request[use_call]
|
||||
try:
|
||||
result: ModbusResponse = await entry.func(address, value, **kwargs)
|
||||
result: ModbusPDU = await entry.func(address, value, **kwargs)
|
||||
except ModbusException as exception_error:
|
||||
error = f"Error: device: {slave} address: {address} -> {exception_error!s}"
|
||||
self._log_error(error)
|
||||
@ -403,7 +402,7 @@ class ModbusHub:
|
||||
address: int,
|
||||
value: int | list[int],
|
||||
use_call: str,
|
||||
) -> ModbusResponse | None:
|
||||
) -> ModbusPDU | None:
|
||||
"""Convert async to sync pymodbus call."""
|
||||
if self._config_delay:
|
||||
return None
|
||||
|
@ -2091,7 +2091,7 @@ pymitv==1.4.3
|
||||
pymochad==0.2.0
|
||||
|
||||
# homeassistant.components.modbus
|
||||
pymodbus==3.6.9
|
||||
pymodbus==3.7.4
|
||||
|
||||
# homeassistant.components.monoprice
|
||||
pymonoprice==0.4
|
||||
|
@ -1696,7 +1696,7 @@ pymicro-vad==1.0.1
|
||||
pymochad==0.2.0
|
||||
|
||||
# homeassistant.components.modbus
|
||||
pymodbus==3.6.9
|
||||
pymodbus==3.7.4
|
||||
|
||||
# homeassistant.components.monoprice
|
||||
pymonoprice==0.4
|
||||
|
@ -19,7 +19,7 @@ from unittest import mock
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from pymodbus.exceptions import ModbusException
|
||||
from pymodbus.pdu import ExceptionResponse, IllegalFunctionRequest
|
||||
from pymodbus.pdu import ExceptionResponse
|
||||
import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
@ -820,7 +820,6 @@ SERVICE = "service"
|
||||
[
|
||||
{VALUE: ReadResult([0x0001]), DATA: ""},
|
||||
{VALUE: ExceptionResponse(0x06), DATA: "Pymodbus:"},
|
||||
{VALUE: IllegalFunctionRequest(0x06), DATA: "Pymodbus:"},
|
||||
{VALUE: ModbusException("fail write_"), DATA: "Pymodbus:"},
|
||||
],
|
||||
)
|
||||
@ -928,7 +927,6 @@ async def mock_modbus_read_pymodbus_fixture(
|
||||
("do_return", "do_exception", "do_expect_state", "do_expect_value"),
|
||||
[
|
||||
(ReadResult([1]), None, STATE_ON, "1"),
|
||||
(IllegalFunctionRequest(0x99), None, STATE_UNAVAILABLE, STATE_UNAVAILABLE),
|
||||
(ExceptionResponse(0x99), None, STATE_UNAVAILABLE, STATE_UNAVAILABLE),
|
||||
(
|
||||
ReadResult([1]),
|
||||
|
Loading…
x
Reference in New Issue
Block a user