Skip to content

Commit

Permalink
Review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen committed Sep 12, 2023
1 parent 9d231a0 commit ddfdbd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion homeassistant/components/modbus/base_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ async def async_update(self, now: datetime | None = None) -> None:
def async_run(self) -> None:
"""Remote start entity."""
self.async_hold(update=False)
async_call_later(self.hass, timedelta(milliseconds=100), self.async_update)
self._cancel_call = async_call_later(
self.hass, timedelta(milliseconds=100), self.async_update
)
if self._scan_interval > 0:
self._cancel_timer = async_track_time_interval(
self.hass, self.async_update, timedelta(seconds=self._scan_interval)
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/modbus/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,16 @@ async def async_update(self, now: datetime | None = None) -> None:
"""Update the state of the sensor."""
# remark "now" is a dummy parameter to avoid problems with
# async_track_time_interval
self._cancel_call = None
raw_result = await self._hub.async_pb_call(
self._slave, self._address, self._count, self._input_type
)
if raw_result is None:
if self._lazy_errors:
self._lazy_errors -= 1
async_call_later(self.hass, timedelta(seconds=1), self.async_update)
self._cancel_call = async_call_later(
self.hass, timedelta(seconds=1), self.async_update
)
return
self._lazy_errors = self._lazy_error_count
self._attr_available = False
Expand Down

0 comments on commit ddfdbd3

Please sign in to comment.