From f55bbbb43a2d41cbc6d5468cbfa23278f9e67f96 Mon Sep 17 00:00:00 2001 From: Guzz-T Date: Tue, 17 Mar 2026 18:56:06 +0100 Subject: [PATCH 1/2] Return True if there is no modbus data to write --- luxtronik/shi/modbus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luxtronik/shi/modbus.py b/luxtronik/shi/modbus.py index a298c967..43bd153d 100644 --- a/luxtronik/shi/modbus.py +++ b/luxtronik/shi/modbus.py @@ -299,7 +299,7 @@ def send(self, telegrams): # Exit the function if no operation is necessary if total_count <= 0: - return False + return True # Acquire lock, connect and read/write data. Disconnect afterwards. success = False From c974753cc64a0c23281992020bf07e1904697cda Mon Sep 17 00:00:00 2001 From: Guzz-T Date: Tue, 17 Mar 2026 22:14:26 +0100 Subject: [PATCH 2/2] Adapt pytest to new modbus behavior --- tests/shi/test_shi_modbus.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/shi/test_shi_modbus.py b/tests/shi/test_shi_modbus.py index 1d0145ee..3f6b1442 100644 --- a/tests/shi/test_shi_modbus.py +++ b/tests/shi/test_shi_modbus.py @@ -157,7 +157,7 @@ def test_no_holdings_read_data(self): # Read zero holdings result = self.modbus_interface.send(data_list) - assert not result + assert result # no error when there is no data assert data_list[0].data == [] assert data_list[1].data == [] @@ -167,7 +167,7 @@ def test_no_holdings_write_data(self): # Write zero holdings result = self.modbus_interface.send(data_list) - assert not result + assert result # no error when there is no data def test_no_inputs_read_data(self): @@ -175,7 +175,7 @@ def test_no_inputs_read_data(self): # Read zero inputs result = self.modbus_interface.send(data_list) - assert not result + assert result # no error when there is no data assert data_list[0].data == [] assert data_list[1].data == [] @@ -185,7 +185,7 @@ def test_no_inputs_read_data(self): [ (1, 2, True, [1, 2]), (5, 3, True, [5, 6, 7]), - (0, 0, False, []), + (0, 0, True, []), # no error when there is no data (1000, 2, False, None), # client has read error (1001, 3, False, None), # client returns to less data (1002, 4, False, None), # client returns to much data @@ -213,7 +213,7 @@ def test_read_holdings(self, addr, count, valid, data): [ (1, 2, True, [1, 2]), (5, 3, True, [5, 6, 7]), - (0, 0, False, []), + (0, 0, True, []), # no error when there is no data (1000, 2, False, None), # client has read error (1001, 3, False, None), # client returns to less data (1002, 4, False, None), # client returns to much data @@ -241,7 +241,7 @@ def test_read_inputs(self, addr, count, valid, data): [ (1, [1, 2], True), (5, [5, 6, 7], True), - (0, [], False), + (0, [], True), # no error when there is no data (1000, [8, 9], False), # Write error (1001, [11], False), # Exception ]