Do not close non existing clients in modbus (#49489)

* Only close if _client is present.

* Remove del.
pull/49520/head
jan iversen 2021-04-21 11:46:40 +02:00 committed by GitHub
parent 6e22251e1d
commit c9bdc9609c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -209,11 +209,11 @@ class ModbusHub:
"""Disconnect client."""
with self._lock:
try:
if self._client:
self._client.close()
del self._client
self._client = None
except ModbusException as exception_error:
self._log_error(exception_error, error_state=False)
self._log_error(exception_error)
return
def connect(self):