Reolink check firmware (#88903)

pull/73549/head
starkillerOG 2023-03-15 18:54:28 +01:00 committed by GitHub
parent dea29f539f
commit 4eee626770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 0 deletions

View File

@ -138,6 +138,26 @@ class ReolinkHost:
await self.subscribe()
if self._api.sw_version_update_required:
ir.async_create_issue(
self._hass,
DOMAIN,
"firmware_update",
is_fixable=False,
severity=ir.IssueSeverity.WARNING,
translation_key="firmware_update",
translation_placeholders={
"required_firmware": self._api.sw_version_required.version_string,
"current_firmware": self._api.sw_version,
"model": self._api.model,
"hw_version": self._api.hardware_version,
"name": self._api.nvr_name,
"download_link": "https://reolink.com/download-center/",
},
)
else:
ir.async_delete_issue(self._hass, DOMAIN, "firmware_update")
async def update_states(self) -> None:
"""Call the API of the camera device to update the internal states."""
await self._api.get_states()

View File

@ -46,6 +46,10 @@
"enable_port": {
"title": "Reolink port not enabled",
"description": "Failed to automatically enable {ports}port(s) on {name}. Use the [Reolink client]({info_link}) to manually set it to ON"
},
"firmware_update": {
"title": "Reolink firmware update required",
"description": "\"{name}\" with model \"{model}\" and hardware version \"{hw_version}\" is running a old firmware version \"{current_firmware}\", while at least firmware version \"{required_firmware}\" is required for proper operation of the Reolink integration. The latest firmware can be downloaded from the [Reolink download center]({download_link})."
}
},
"entity": {

View File

@ -100,6 +100,7 @@ async def test_no_repair_issue(
issue_registry = ir.async_get(hass)
assert (const.DOMAIN, "https_webhook") not in issue_registry.issues
assert (const.DOMAIN, "enable_port") not in issue_registry.issues
assert (const.DOMAIN, "firmware_update") not in issue_registry.issues
async def test_https_repair_issue(
@ -135,3 +136,15 @@ async def test_port_repair_issue(
issue_registry = ir.async_get(hass)
assert (const.DOMAIN, "enable_port") in issue_registry.issues
async def test_firmware_repair_issue(
hass: HomeAssistant, config_entry: MockConfigEntry, reolink_connect: MagicMock
) -> None:
"""Test firmware issue is raised when too old firmware is used."""
reolink_connect.sw_version_update_required = True
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
issue_registry = ir.async_get(hass)
assert (const.DOMAIN, "firmware_update") in issue_registry.issues