Harden modbus against lib errors (#100469)

This commit is contained in:
jan iversen 2023-09-16 09:57:55 +02:00 committed by GitHub
parent a111988232
commit d25f45a957
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 4 deletions

View file

@ -419,9 +419,15 @@ class ModbusHub:
except ModbusException as exception_error:
self._log_error(str(exception_error))
return None
if not result:
self._log_error("Error: pymodbus returned None")
return None
if not hasattr(result, entry.attr):
self._log_error(str(result))
return None
if result.isError(): # type: ignore[no-untyped-call]
self._log_error("Error: pymodbus returned isError True")
return None
self._in_error = False
return result