Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions homeassistant/components/unifiprotect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from aiohttp.client_exceptions import ServerDisconnectedError
from pyunifiprotect.data import Bootstrap
from pyunifiprotect.data.types import FirmwareReleaseChannel
from pyunifiprotect.exceptions import ClientError, NotAuthorized

# Import the test_util.anonymize module from the pyunifiprotect package
Expand Down Expand Up @@ -112,19 +113,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, data_service.async_stop)
)

if (
not entry.options.get(CONF_ALLOW_EA, False)
and await nvr_info.get_is_prerelease()
if not entry.options.get(CONF_ALLOW_EA, False) and (
await nvr_info.get_is_prerelease()
or nvr_info.release_channel != FirmwareReleaseChannel.RELEASE
):
ir.async_create_issue(
hass,
DOMAIN,
"ea_warning",
"ea_channel_warning",
is_fixable=True,
is_persistent=True,
learn_more_url="https://www.home-assistant.io/integrations/unifiprotect#about-unifi-early-access",
severity=IssueSeverity.WARNING,
translation_key="ea_warning",
translation_key="ea_channel_warning",
translation_placeholders={"version": str(nvr_info.version)},
data={"entry_id": entry.entry_id},
)
Expand All @@ -150,7 +151,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"version": str(nvr_info.version),
},
)
ir.async_delete_issue(hass, DOMAIN, "ea_warning")
ir.async_delete_issue(hass, DOMAIN, "ea_channel_warning")
_LOGGER.exception("Error setting up UniFi Protect integration: %s", err)
raise

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/unifiprotect/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
CONF_ALL_UPDATES = "all_updates"
CONF_OVERRIDE_CHOST = "override_connection_host"
CONF_MAX_MEDIA = "max_media"
CONF_ALLOW_EA = "allow_ea"
CONF_ALLOW_EA = "allow_ea_channel"

CONFIG_OPTIONS = [
CONF_ALL_UPDATES,
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/unifiprotect/repairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import cast

from pyunifiprotect import ProtectApiClient
from pyunifiprotect.data.types import FirmwareReleaseChannel
import voluptuous as vol

from homeassistant import data_entry_flow
Expand Down Expand Up @@ -68,7 +69,7 @@ async def async_step_start(
)

nvr = await self._api.get_nvr()
if await nvr.get_is_prerelease():
if nvr.release_channel != FirmwareReleaseChannel.RELEASE:
return await self.async_step_confirm()
await self.hass.config_entries.async_reload(self._entry.entry_id)
return self.async_create_entry(data={})
Expand Down Expand Up @@ -124,7 +125,7 @@ async def async_create_fix_flow(
data: dict[str, str | int | float | None] | None,
) -> RepairsFlow:
"""Create flow."""
if data is not None and issue_id == "ea_warning":
if data is not None and issue_id == "ea_channel_warning":
entry_id = cast(str, data["entry_id"])
if (entry := hass.config_entries.async_get_entry(entry_id)) is not None:
api = async_create_api_client(hass, entry)
Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/unifiprotect/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,24 @@
}
},
"issues": {
"ea_warning": {
"title": "UniFi Protect v{version} is an Early Access version",
"ea_channel_warning": {
"title": "UniFi Protect Early Access enabled",
"fix_flow": {
"step": {
"start": {
"title": "v{version} is an Early Access version",
"description": "You are using v{version} of UniFi Protect which is an Early Access version. [Early Access versions are not supported by Home Assistant](https://www.home-assistant.io/integrations/unifiprotect#about-unifi-early-access) and it is recommended to go back to a stable release as soon as possible.\n\nBy submitting this form you have either [downgraded UniFi Protect](https://www.home-assistant.io/integrations/unifiprotect#downgrading-unifi-protect) or you agree to run an unsupported version of UniFi Protect."
"title": "UniFi Protect Early Access enabled",
"description": "You are either running an Early Access version of UniFi Protect (v{version}) or you have opt-ed into a release channel that is not the Official stable release channel. [Early Access versions are not supported by Home Assistant](https://www.home-assistant.io/integrations/unifiprotect#about-unifi-early-access) and you should switch back to the Official stable release channel as soon as possible. Accidentally upgrading to an Early Access version can break your UniFi Protect integration.\n\nBy submitting this form you have switched back to the official release channel or you agree to run an unsupported version of UniFi Protect which may break your Home Assistant integration at anytime."
Comment thread
AngellusMortis marked this conversation as resolved.
Outdated
},
"confirm": {
"title": "[%key:component::unifiprotect::issues::ea_warning::fix_flow::step::start::title%]",
"title": "[%key:component::unifiprotect::issues::ea_channel_warning::fix_flow::step::start::title%]",
"description": "Are you sure you want to run unsupported versions of UniFi Protect? This may cause your Home Assistant integration to break."
}
}
}
},
"ea_setup_failed": {
"title": "Setup error using Early Access version",
"description": "You are using v{version} of UniFi Protect which is an Early Access version. An unrecoverable error occurred while trying to load the integration. Please [downgrade to a stable version](https://www.home-assistant.io/integrations/unifiprotect#downgrading-unifi-protect) of UniFi Protect to continue using the integration.\n\nError: {error}"
"description": "You are using v{version} of UniFi Protect which is an Early Access version. An unrecoverable error occurred while trying to load the integration. Please restore a backup of a stable release of UniFi Protect to continue using the integration.\n\nError: {error}"
},
"cloud_user": {
"title": "Ubiquiti Cloud Users are not Supported",
Expand Down
2 changes: 1 addition & 1 deletion tests/components/unifiprotect/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ async def test_form_options(hass: HomeAssistant, ufp_client: ProtectApiClient) -
"disable_rtsp": True,
"override_connection_host": True,
"max_media": 1000,
"allow_ea": False,
"allow_ea_channel": False,
}
await hass.config_entries.async_unload(mock_config.entry_id)

Expand Down
15 changes: 10 additions & 5 deletions tests/components/unifiprotect/test_repairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ async def test_ea_warning_ignore(
assert len(msg["result"]["issues"]) > 0
issue = None
for i in msg["result"]["issues"]:
if i["issue_id"] == "ea_warning":
if i["issue_id"] == "ea_channel_warning":
issue = i
assert issue is not None

url = RepairsFlowIndexView.url
resp = await client.post(url, json={"handler": DOMAIN, "issue_id": "ea_warning"})
resp = await client.post(
url, json={"handler": DOMAIN, "issue_id": "ea_channel_warning"}
)
assert resp.status == HTTPStatus.OK
data = await resp.json()

Expand Down Expand Up @@ -104,12 +106,14 @@ async def test_ea_warning_fix(
assert len(msg["result"]["issues"]) > 0
issue = None
for i in msg["result"]["issues"]:
if i["issue_id"] == "ea_warning":
if i["issue_id"] == "ea_channel_warning":
issue = i
assert issue is not None

url = RepairsFlowIndexView.url
resp = await client.post(url, json={"handler": DOMAIN, "issue_id": "ea_warning"})
resp = await client.post(
url, json={"handler": DOMAIN, "issue_id": "ea_channel_warning"}
)
assert resp.status == HTTPStatus.OK
data = await resp.json()

Expand All @@ -122,8 +126,9 @@ async def test_ea_warning_fix(

new_nvr = copy(ufp.api.bootstrap.nvr)
new_nvr.version = Version("2.2.6")
new_nvr.release_channel = "release"
mock_msg = Mock()
mock_msg.changed_data = {"version": "2.2.6"}
mock_msg.changed_data = {"version": "2.2.6", "releaseChannel": "release"}
mock_msg.new_obj = new_nvr

ufp.api.bootstrap.nvr = new_nvr
Expand Down