Skip to content

Commit 3f34204

Browse files
Merge branch 'main' into code-quality
2 parents b5c8727 + b178741 commit 3f34204

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

custom_components/solaredge_modbus_multi/hub.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ async def async_refresh_modbus_data(self) -> bool:
385385
raise DataUpdateFailed(f"Modbus error: {e}")
386386

387387
except TimeoutError as e:
388-
self.disconnect()
388+
self.disconnect(clear_client=True)
389389
self._timeout_counter += 1
390390

391391
_LOGGER.debug(
@@ -413,6 +413,7 @@ async def connect(self) -> None:
413413
"""Connect to inverter."""
414414

415415
if self._client is None:
416+
_LOGGER.debug(f"New client object for {self._host}:{self._port}")
416417
self._client = AsyncModbusTcpClient(
417418
host=self._host,
418419
port=self._port,
@@ -424,18 +425,21 @@ async def connect(self) -> None:
424425

425426
await self._client.connect()
426427

427-
def disconnect(self) -> None:
428+
def disconnect(self, clear_client: bool = False) -> None:
428429
"""Disconnect from inverter."""
429430

430431
if self._client is not None:
431432
self._client.close()
432433

434+
if clear_client:
435+
self._client = None
436+
433437
async def shutdown(self) -> None:
434438
"""Shut down the hub and disconnect."""
439+
435440
async with self._lock:
436441
self.online = False
437-
self.disconnect()
438-
self._client = None
442+
self.disconnect(clear_client=True)
439443

440444
async def modbus_read_holding_registers(self, unit, address, rcount):
441445
"""Read modbus registers from inverter."""

custom_components/solaredge_modbus_multi/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"issue_tracker": "https://github.com/WillCodeForCats/solaredge-modbus-multi/issues",
1111
"loggers": ["custom_components.solaredge_modbus_multi"],
1212
"requirements": ["pymodbus>=3.5.4"],
13-
"version": "2.4.11-pre.1"
13+
"version": "2.4.12-pre.1"
1414
}

0 commit comments

Comments
 (0)