1 """Support for La Marzocco update entities."""
3 from dataclasses
import dataclass
6 from pylamarzocco.const
import FirmwareType
7 from pylamarzocco.exceptions
import RequestNotSuccessful
12 UpdateEntityDescription,
20 from .const
import DOMAIN
21 from .coordinator
import LaMarzoccoConfigEntry
22 from .entity
import LaMarzoccoEntity, LaMarzoccoEntityDescription
27 @dataclass(frozen=True, kw_only=True)
29 LaMarzoccoEntityDescription,
30 UpdateEntityDescription,
32 """Description of a La Marzocco update entities."""
34 component: FirmwareType
37 ENTITIES: tuple[LaMarzoccoUpdateEntityDescription, ...] = (
39 key=
"machine_firmware",
40 translation_key=
"machine_firmware",
41 device_class=UpdateDeviceClass.FIRMWARE,
42 component=FirmwareType.MACHINE,
43 entity_category=EntityCategory.DIAGNOSTIC,
46 key=
"gateway_firmware",
47 translation_key=
"gateway_firmware",
48 device_class=UpdateDeviceClass.FIRMWARE,
49 component=FirmwareType.GATEWAY,
50 entity_category=EntityCategory.DIAGNOSTIC,
57 entry: LaMarzoccoConfigEntry,
58 async_add_entities: AddEntitiesCallback,
60 """Create update entities."""
62 coordinator = entry.runtime_data
65 for description
in ENTITIES
66 if description.supported_fn(coordinator)
71 """Entity representing the update state."""
73 entity_description: LaMarzoccoUpdateEntityDescription
74 _attr_supported_features = UpdateEntityFeature.INSTALL
78 """Return the current firmware version."""
79 return self.coordinator.device.firmware[
85 """Return the latest firmware version."""
86 return self.coordinator.device.firmware[
92 """Return the release notes URL."""
93 return "https://support-iot.lamarzocco.com/firmware-updates/"
96 self, version: str |
None, backup: bool, **kwargs: Any
98 """Install an update."""
102 success = await self.coordinator.device.update_firmware(
105 except RequestNotSuccessful
as exc:
107 translation_domain=DOMAIN,
108 translation_key=
"update_failed",
109 translation_placeholders={
115 translation_domain=DOMAIN,
116 translation_key=
"update_failed",
117 translation_placeholders={
str|None release_url(self)
None async_install(self, str|None version, bool backup, **Any kwargs)
None async_write_ha_state(self)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, LaMarzoccoConfigEntry entry, AddEntitiesCallback async_add_entities)