Fix Litter-Robot 4 firmware versions reported while updating (#85710)
This commit is contained in:
parent
b14c141fe3
commit
0ae855d345
5 changed files with 43 additions and 11 deletions
|
@ -3,7 +3,7 @@
|
||||||
"name": "Litter-Robot",
|
"name": "Litter-Robot",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/litterrobot",
|
"documentation": "https://www.home-assistant.io/integrations/litterrobot",
|
||||||
"requirements": ["pylitterbot==2023.1.0"],
|
"requirements": ["pylitterbot==2023.1.1"],
|
||||||
"codeowners": ["@natekspencer", "@tkdrob"],
|
"codeowners": ["@natekspencer", "@tkdrob"],
|
||||||
"dhcp": [{ "hostname": "litter-robot4" }],
|
"dhcp": [{ "hostname": "litter-robot4" }],
|
||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
|
|
|
@ -69,19 +69,20 @@ class RobotUpdateEntity(LitterRobotEntity[LitterRobot4], UpdateEntity):
|
||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Update the entity."""
|
"""Update the entity."""
|
||||||
if await self.robot.has_firmware_update():
|
# If the robot has a firmware update already in progress, checking for the
|
||||||
latest_version = await self.robot.get_latest_firmware()
|
# latest firmware informs that an update has already been triggered, no
|
||||||
else:
|
# firmware information is returned and we won't know the latest version.
|
||||||
latest_version = self.installed_version
|
if not self.robot.firmware_update_triggered:
|
||||||
|
latest_version = await self.robot.get_latest_firmware(True)
|
||||||
if self._attr_latest_version != self.installed_version:
|
if not await self.robot.has_firmware_update():
|
||||||
|
latest_version = self.robot.firmware
|
||||||
self._attr_latest_version = latest_version
|
self._attr_latest_version = latest_version
|
||||||
|
|
||||||
async def async_install(
|
async def async_install(
|
||||||
self, version: str | None, backup: bool, **kwargs: Any
|
self, version: str | None, backup: bool, **kwargs: Any
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Install an update."""
|
"""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():
|
if not await self.robot.update_firmware():
|
||||||
message = f"Unable to start firmware update on {self.robot.name}"
|
message = f"Unable to start firmware update on {self.robot.name}"
|
||||||
raise HomeAssistantError(message)
|
raise HomeAssistantError(message)
|
||||||
|
|
|
@ -1741,7 +1741,7 @@ pylibrespot-java==0.1.1
|
||||||
pylitejet==0.3.0
|
pylitejet==0.3.0
|
||||||
|
|
||||||
# homeassistant.components.litterrobot
|
# homeassistant.components.litterrobot
|
||||||
pylitterbot==2023.1.0
|
pylitterbot==2023.1.1
|
||||||
|
|
||||||
# homeassistant.components.lutron_caseta
|
# homeassistant.components.lutron_caseta
|
||||||
pylutron-caseta==0.17.1
|
pylutron-caseta==0.17.1
|
||||||
|
|
|
@ -1248,7 +1248,7 @@ pylibrespot-java==0.1.1
|
||||||
pylitejet==0.3.0
|
pylitejet==0.3.0
|
||||||
|
|
||||||
# homeassistant.components.litterrobot
|
# homeassistant.components.litterrobot
|
||||||
pylitterbot==2023.1.0
|
pylitterbot==2023.1.1
|
||||||
|
|
||||||
# homeassistant.components.lutron_caseta
|
# homeassistant.components.lutron_caseta
|
||||||
pylutron-caseta==0.17.1
|
pylutron-caseta==0.17.1
|
||||||
|
|
|
@ -11,7 +11,13 @@ from homeassistant.components.update import (
|
||||||
SERVICE_INSTALL,
|
SERVICE_INSTALL,
|
||||||
UpdateDeviceClass,
|
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.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
|
@ -28,6 +34,7 @@ async def test_robot_with_no_update(
|
||||||
"""Tests the update entity was set up."""
|
"""Tests the update entity was set up."""
|
||||||
robot: LitterRobot4 = mock_account_with_litterrobot_4.robots[0]
|
robot: LitterRobot4 = mock_account_with_litterrobot_4.robots[0]
|
||||||
robot.has_firmware_update = AsyncMock(return_value=False)
|
robot.has_firmware_update = AsyncMock(return_value=False)
|
||||||
|
robot.get_latest_firmware = AsyncMock(return_value=None)
|
||||||
|
|
||||||
entry = await setup_integration(
|
entry = await setup_integration(
|
||||||
hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN
|
hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN
|
||||||
|
@ -79,3 +86,27 @@ async def test_robot_with_update(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert robot.update_firmware.call_count == 1
|
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…
Add table
Add a link
Reference in a new issue