mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
ESPHome update: Store reference to runtime data, not one of its values (#86762)
Store reference to runtime data, not one of its values
This commit is contained in:
parent
e738924780
commit
687184138c
@ -72,15 +72,13 @@ class ESPHomeUpdateEntity(CoordinatorEntity[ESPHomeDashboard], UpdateEntity):
|
|||||||
_attr_title = "ESPHome"
|
_attr_title = "ESPHome"
|
||||||
_attr_name = "Firmware"
|
_attr_name = "Firmware"
|
||||||
|
|
||||||
_device_info: ESPHomeDeviceInfo
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, entry_data: RuntimeEntryData, coordinator: ESPHomeDashboard
|
self, entry_data: RuntimeEntryData, coordinator: ESPHomeDashboard
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the update entity."""
|
"""Initialize the update entity."""
|
||||||
super().__init__(coordinator=coordinator)
|
super().__init__(coordinator=coordinator)
|
||||||
assert entry_data.device_info is not None
|
assert entry_data.device_info is not None
|
||||||
self._device_info = entry_data.device_info
|
self._entry_data = entry_data
|
||||||
self._attr_unique_id = entry_data.device_info.mac_address
|
self._attr_unique_id = entry_data.device_info.mac_address
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
connections={
|
connections={
|
||||||
@ -88,6 +86,12 @@ class ESPHomeUpdateEntity(CoordinatorEntity[ESPHomeDashboard], UpdateEntity):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _device_info(self) -> ESPHomeDeviceInfo:
|
||||||
|
"""Return the device info."""
|
||||||
|
assert self._entry_data.device_info is not None
|
||||||
|
return self._entry_data.device_info
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return if update is available."""
|
"""Return if update is available."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user