Fix Litter-Robot 4 firmware versions reported while updating (#85710)

This commit is contained in:
Nathan Spencer 2023-01-11 19:53:06 -07:00 committed by GitHub
parent b14c141fe3
commit 0ae855d345
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 11 deletions

View file

@ -69,19 +69,20 @@ class RobotUpdateEntity(LitterRobotEntity[LitterRobot4], UpdateEntity):
async def async_update(self) -> None:
"""Update the entity."""
if await self.robot.has_firmware_update():
latest_version = await self.robot.get_latest_firmware()
else:
latest_version = self.installed_version
if self._attr_latest_version != self.installed_version:
# If the robot has a firmware update already in progress, checking for the
# latest firmware informs that an update has already been triggered, no
# firmware information is returned and we won't know the latest version.
if not self.robot.firmware_update_triggered:
latest_version = await self.robot.get_latest_firmware(True)
if not await self.robot.has_firmware_update():
latest_version = self.robot.firmware
self._attr_latest_version = latest_version
async def async_install(
self, version: str | None, backup: bool, **kwargs: Any
) -> None:
"""Install an update."""
if await self.robot.has_firmware_update():
if await self.robot.has_firmware_update(True):
if not await self.robot.update_firmware():
message = f"Unable to start firmware update on {self.robot.name}"
raise HomeAssistantError(message)