Extend Reolink update entity (#94323)

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
pull/95443/head
starkillerOG 2023-06-28 13:32:14 +02:00 committed by GitHub
parent c2cd4d0517
commit ee4459f41e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import logging
from typing import Any, Literal
from reolink_aio.exceptions import ReolinkError
from reolink_aio.software_version import NewSoftwareVersion
from homeassistant.components.update import (
UpdateDeviceClass,
@ -39,7 +40,6 @@ class ReolinkUpdateEntity(
"""Update entity for a Netgear device."""
_attr_device_class = UpdateDeviceClass.FIRMWARE
_attr_supported_features = UpdateEntityFeature.INSTALL
_attr_release_url = "https://reolink.com/download-center/"
_attr_name = "Update"
@ -68,6 +68,26 @@ class ReolinkUpdateEntity(
return self.coordinator.data.version_string
@property
def supported_features(self) -> UpdateEntityFeature:
"""Flag supported features."""
supported_features = UpdateEntityFeature.INSTALL
if isinstance(self.coordinator.data, NewSoftwareVersion):
supported_features |= UpdateEntityFeature.RELEASE_NOTES
return supported_features
async def async_release_notes(self) -> str | None:
"""Return the release notes."""
if not isinstance(self.coordinator.data, NewSoftwareVersion):
return None
return (
"If the install button fails, download this"
f" [firmware zip file]({self.coordinator.data.download_url})."
" Then, follow the installation guide (PDF in the zip file).\n\n"
f"## Release notes\n\n{self.coordinator.data.release_notes}"
)
async def async_install(
self, version: str | None, backup: bool, **kwargs: Any
) -> None: