Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow smlight device to reboot before updating firmware data coordinator #127442

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions homeassistant/components/smlight/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ def _update_progress(self, progress: MessageEvent) -> None:
def _update_done(self) -> None:
"""Handle cleanup for update done."""
self._finished_event.set()
self.coordinator.in_progress = False

for remove_cb in self._unload:
remove_cb()
Expand All @@ -175,7 +174,7 @@ def _update_finished(self, event: MessageEvent) -> None:
@callback
def _update_failed(self, event: MessageEvent) -> None:
self._update_done()

self.coordinator.in_progress = False
raise HomeAssistantError(f"Update failed for {self.name}")

async def async_install(
Expand All @@ -193,5 +192,13 @@ async def async_install(
# block until update finished event received
await self._finished_event.wait()

await self.coordinator.async_refresh()
# allow time for SLZB-06 to reboot before updating coordinator data
while (
self.coordinator.in_progress
and self.installed_version != self._firmware.ver
):
await self.coordinator.async_refresh()
await asyncio.sleep(0)

self.coordinator.in_progress = False
self._finished_event.clear()
3 changes: 2 additions & 1 deletion tests/components/smlight/test_update.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for the SMLIGHT update platform."""

from datetime import timedelta
from unittest.mock import MagicMock

from freezegun.api import FrozenDateTimeFactory
Expand Down Expand Up @@ -124,7 +125,7 @@ async def test_update_firmware(
sw_version="v2.5.2",
)

freezer.tick(SCAN_FIRMWARE_INTERVAL)
freezer.tick(timedelta(seconds=5))
async_fire_time_changed(hass)
await hass.async_block_till_done()

Expand Down