mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Do not close non existing clients in modbus (#49489)
* Only close if _client is present. * Remove del.
This commit is contained in:
parent
6e22251e1d
commit
c9bdc9609c
@ -209,11 +209,11 @@ class ModbusHub:
|
|||||||
"""Disconnect client."""
|
"""Disconnect client."""
|
||||||
with self._lock:
|
with self._lock:
|
||||||
try:
|
try:
|
||||||
self._client.close()
|
if self._client:
|
||||||
del self._client
|
self._client.close()
|
||||||
self._client = None
|
self._client = None
|
||||||
except ModbusException as exception_error:
|
except ModbusException as exception_error:
|
||||||
self._log_error(exception_error, error_state=False)
|
self._log_error(exception_error)
|
||||||
return
|
return
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user