Add lazy_error_count to modbus (#54412)
* Add lazy_error_count. * Use -= * Review comments.
This commit is contained in:
parent
51434c5faa
commit
33f660118f
15 changed files with 47 additions and 1 deletions
|
@ -57,10 +57,15 @@ class ModbusBinarySensor(BasePlatform, RestoreEntity, BinarySensorEntity):
|
|||
)
|
||||
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
|
||||
|
||||
self._lazy_errors = self._lazy_error_count
|
||||
self._attr_is_on = result.bits[0] & 1
|
||||
self._attr_available = True
|
||||
self.async_write_ha_state()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue