Reset Modbus value on down (#86127)

* modbus: slave should reset value on sensor down as parent does that

* modbus: slave should reset value on sensor down as parent does that
This commit is contained in:
GrahamJB1 2023-01-18 07:49:38 +00:00 committed by GitHub
parent 0b45fb6dc3
commit 9d9817328b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 4 deletions

View file

@ -153,6 +153,5 @@ class SlaveSensor(
def _handle_coordinator_update(self) -> None: def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator.""" """Handle updated data from the coordinator."""
result = self.coordinator.data result = self.coordinator.data
if result: self._attr_is_on = bool(result[self._result_inx] & 1) if result else None
self._attr_is_on = bool(result[self._result_inx] & 1)
super()._handle_coordinator_update() super()._handle_coordinator_update()

View file

@ -156,6 +156,5 @@ class SlaveSensor(
def _handle_coordinator_update(self) -> None: def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator.""" """Handle updated data from the coordinator."""
result = self.coordinator.data result = self.coordinator.data
if result: self._attr_native_value = result[self._idx] if result else None
self._attr_native_value = result[self._idx]
super()._handle_coordinator_update() super()._handle_coordinator_update()