1 """Update entities for Linn devices."""
3 from __future__
import annotations
9 from async_upnp_client.client
import UpnpError
22 from .const
import DOMAIN
24 _LOGGER = logging.getLogger(__name__)
29 config_entry: ConfigEntry,
30 async_add_entities: AddEntitiesCallback,
32 """Set up update entities for Reolink component."""
34 _LOGGER.debug(
"Setting up config entry: %s", config_entry.unique_id)
36 device = hass.data[DOMAIN][config_entry.entry_id]
40 await entity.async_update()
46 """Update entity for a Linn DS device."""
48 _attr_device_class = UpdateDeviceClass.FIRMWARE
49 _attr_supported_features = UpdateEntityFeature.INSTALL
50 _attr_has_entity_name =
True
54 """Initialize a Linn DS update entity."""
59 (DOMAIN, device.uuid()),
61 manufacturer=device.manufacturer(),
62 model=device.model_name(),
63 name=device.friendly_name(),
67 """Update state of entity."""
69 software_status = await self.
_device_device.software_status()
71 if not software_status:
80 if software_status[
"status"] ==
"update_available":
87 self.
_attr_release_url_attr_release_url = software_status[
"update_info"][
"releasenotesuri"]
90 self, version: str |
None, backup: bool, **kwargs: Any
92 """Install the latest firmware version."""
95 await self.
_device_device.update_firmware()
96 except (TimeoutError, aiohttp.ClientError, UpnpError)
as err:
98 f
"Error updating {self._device.device.friendly_name}: {err}"
def __init__(self, device)
None async_install(self, str|None version, bool backup, **Any kwargs)
str|None latest_version(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)