Check Reolink IPC channels for firmware repair issue (#119241)

* Add IPC channels to firmware repair issue

* fix tests

* fix typo
This commit is contained in:
starkillerOG 2024-06-21 11:57:48 +02:00 committed by GitHub
parent ecd61c6b6d
commit c8ce935ec7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 21 deletions

View file

@ -228,7 +228,7 @@ def migrate_entity_ids(
entity_reg = er.async_get(hass)
entities = er.async_entries_for_config_entry(entity_reg, config_entry_id)
for entity in entities:
# Can be remove in HA 2025.1.0
# Can be removed in HA 2025.1.0
if entity.domain == "update" and entity.unique_id == host.unique_id:
entity_reg.async_update_entity(
entity.entity_id, new_unique_id=f"{host.unique_id}_firmware"

View file

@ -127,6 +127,7 @@ class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
name=self._host.api.camera_name(dev_ch),
model=self._host.api.camera_model(dev_ch),
manufacturer=self._host.api.manufacturer,
hw_version=self._host.api.camera_hardware_version(dev_ch),
sw_version=self._host.api.camera_sw_version(dev_ch),
serial_number=self._host.api.camera_uid(dev_ch),
configuration_url=self._conf_url,

View file

@ -237,25 +237,35 @@ class ReolinkHost:
self._async_check_onvif_long_poll,
)
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")
ch_list: list[int | None] = [None]
if self._api.is_nvr:
ch_list.extend(self._api.channels)
for ch in ch_list:
if not self._api.supported(ch, "firmware"):
continue
key = ch if ch is not None else "host"
if self._api.camera_sw_version_update_required(ch):
ir.async_create_issue(
self._hass,
DOMAIN,
f"firmware_update_{key}",
is_fixable=False,
severity=ir.IssueSeverity.WARNING,
translation_key="firmware_update",
translation_placeholders={
"required_firmware": self._api.camera_sw_version_required(
ch
).version_string,
"current_firmware": self._api.camera_sw_version(ch),
"model": self._api.camera_model(ch),
"hw_version": self._api.camera_hardware_version(ch),
"name": self._api.camera_name(ch),
"download_link": "https://reolink.com/download-center/",
},
)
else:
ir.async_delete_issue(self._hass, DOMAIN, f"firmware_update_{key}")
async def _async_check_onvif(self, *_) -> None:
"""Check the ONVIF subscription."""

View file

@ -330,4 +330,4 @@ async def test_firmware_repair_issue(
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert (const.DOMAIN, "firmware_update") in issue_registry.issues
assert (const.DOMAIN, "firmware_update_host") in issue_registry.issues