Add lazy_error_count to modbus (#54412)

* Add lazy_error_count.

* Use -=

* Review comments.
This commit is contained in:
jan iversen 2021-08-21 15:49:50 +02:00 committed by GitHub
parent 51434c5faa
commit 33f660118f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 47 additions and 1 deletions

View file

@ -146,9 +146,14 @@ class ModbusCover(BasePlatform, CoverEntity, RestoreEntity):
)
self._call_active = False
if result is None:
if self._lazy_errors:
self._lazy_errors -= 1
return
self._lazy_errors = self._lazy_error_count
self._attr_available = False
self.async_write_ha_state()
return None
return
self._lazy_errors = self._lazy_error_count
self._attr_available = True
if self._input_type == CALL_TYPE_COIL:
self._set_attr_state(bool(result.bits[0] & 1))