Skip to content

Commit

Permalink
Reolink check firmware (home-assistant#88903)
Browse files Browse the repository at this point in the history
  • Loading branch information
starkillerOG authored Mar 15, 2023
1 parent dea29f5 commit 4eee626
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
20 changes: 20 additions & 0 deletions homeassistant/components/reolink/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,26 @@ async def async_init(self) -> None:

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()
Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/reolink/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
13 changes: 13 additions & 0 deletions tests/components/reolink/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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

0 comments on commit 4eee626

Please sign in to comment.