Fix Litter-Robot 4 firmware versions reported while updating (#85710)
parent
b14c141fe3
commit
0ae855d345
|
@ -3,7 +3,7 @@
|
|||
"name": "Litter-Robot",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/litterrobot",
|
||||
"requirements": ["pylitterbot==2023.1.0"],
|
||||
"requirements": ["pylitterbot==2023.1.1"],
|
||||
"codeowners": ["@natekspencer", "@tkdrob"],
|
||||
"dhcp": [{ "hostname": "litter-robot4" }],
|
||||
"iot_class": "cloud_push",
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1741,7 +1741,7 @@ pylibrespot-java==0.1.1
|
|||
pylitejet==0.3.0
|
||||
|
||||
# homeassistant.components.litterrobot
|
||||
pylitterbot==2023.1.0
|
||||
pylitterbot==2023.1.1
|
||||
|
||||
# homeassistant.components.lutron_caseta
|
||||
pylutron-caseta==0.17.1
|
||||
|
|
|
@ -1248,7 +1248,7 @@ pylibrespot-java==0.1.1
|
|||
pylitejet==0.3.0
|
||||
|
||||
# homeassistant.components.litterrobot
|
||||
pylitterbot==2023.1.0
|
||||
pylitterbot==2023.1.1
|
||||
|
||||
# homeassistant.components.lutron_caseta
|
||||
pylutron-caseta==0.17.1
|
||||
|
|
|
@ -11,7 +11,13 @@ from homeassistant.components.update import (
|
|||
SERVICE_INSTALL,
|
||||
UpdateDeviceClass,
|
||||
)
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_ENTITY_ID, STATE_OFF, STATE_ON
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
ATTR_ENTITY_ID,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
|
@ -28,6 +34,7 @@ async def test_robot_with_no_update(
|
|||
"""Tests the update entity was set up."""
|
||||
robot: LitterRobot4 = mock_account_with_litterrobot_4.robots[0]
|
||||
robot.has_firmware_update = AsyncMock(return_value=False)
|
||||
robot.get_latest_firmware = AsyncMock(return_value=None)
|
||||
|
||||
entry = await setup_integration(
|
||||
hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN
|
||||
|
@ -79,3 +86,27 @@ async def test_robot_with_update(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
assert robot.update_firmware.call_count == 1
|
||||
|
||||
|
||||
async def test_robot_with_update_already_in_progress(
|
||||
hass: HomeAssistant, mock_account_with_litterrobot_4: MagicMock
|
||||
):
|
||||
"""Tests the update entity was set up."""
|
||||
robot: LitterRobot4 = mock_account_with_litterrobot_4.robots[0]
|
||||
robot._update_data( # pylint:disable=protected-access
|
||||
{"isFirmwareUpdateTriggered": True}, partial=True
|
||||
)
|
||||
|
||||
entry = await setup_integration(
|
||||
hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN
|
||||
)
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == UpdateDeviceClass.FIRMWARE
|
||||
assert state.attributes[ATTR_INSTALLED_VERSION] == OLD_FIRMWARE
|
||||
assert state.attributes[ATTR_LATEST_VERSION] is None
|
||||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
Loading…
Reference in New Issue