From 7463e3f20eaf3166d20f442e490f28461fbd3819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8B=E5=BC=A6=E5=8F=A4=E6=9C=88?= <704170565@qq.com> Date: Thu, 9 Feb 2023 14:20:21 +0800 Subject: [PATCH] Update modbus.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 适配最新版HA2023.2.3 --- custom_components/peacefair_energy/modbus.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/peacefair_energy/modbus.py b/custom_components/peacefair_energy/modbus.py index 269486a..a074da4 100644 --- a/custom_components/peacefair_energy/modbus.py +++ b/custom_components/peacefair_energy/modbus.py @@ -1,5 +1,5 @@ import logging -from pymodbus.client.sync import ModbusTcpClient, ModbusUdpClient +from pymodbus.client import ModbusTcpClient, ModbusUdpClient from pymodbus.transaction import ModbusRtuFramer, ModbusIOException from pymodbus.pdu import ModbusRequest import threading @@ -84,12 +84,12 @@ def read_holding_register(self): def read_input_registers(self, address, count): with self._lock: - kwargs = {"unit": self._slave} + kwargs = {"slave": self._slave} return self._client.read_input_registers(address, count, **kwargs) def reset_energy(self): with self._lock: - kwargs = {"unit": self._slave} + kwargs = {"slave": self._slave} request = ModbusResetEnergyRequest(**kwargs) self._client.execute(request)