1 """Support for Litter-Robot updates."""
3 from __future__
import annotations
5 from datetime
import timedelta
8 from pylitterbot
import LitterRobot4
13 UpdateEntityDescription,
20 from .
import LitterRobotConfigEntry
21 from .entity
import LitterRobotEntity
27 device_class=UpdateDeviceClass.FIRMWARE,
33 entry: LitterRobotConfigEntry,
34 async_add_entities: AddEntitiesCallback,
36 """Set up Litter-Robot update platform."""
37 hub = entry.runtime_data
40 for robot
in hub.litter_robots()
41 if isinstance(robot, LitterRobot4)
47 """A class that describes robot update entities."""
49 _attr_supported_features = (
50 UpdateEntityFeature.INSTALL | UpdateEntityFeature.PROGRESS
55 """Version installed and in use."""
56 return self.
robotrobot.firmware
60 """Update installation progress."""
61 return self.
robotrobot.firmware_update_triggered
65 """Set polling to True."""
69 """Update the entity."""
73 if not self.
robotrobot.firmware_update_triggered:
74 latest_version = await self.
robotrobot.get_latest_firmware(
True)
75 if not await self.
robotrobot.has_firmware_update():
76 latest_version = self.
robotrobot.firmware
80 self, version: str |
None, backup: bool, **kwargs: Any
82 """Install an update."""
83 if await self.
robotrobot.has_firmware_update(
True):
84 if not await self.
robotrobot.update_firmware():
85 message = f
"Unable to start firmware update on {self.robot.name}"
None async_install(self, str|None version, bool backup, **Any kwargs)
None async_setup_entry(HomeAssistant hass, LitterRobotConfigEntry entry, AddEntitiesCallback async_add_entities)