mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Add note to unifiprotect flow that a local user is required (#64651)
This commit is contained in:
parent
8fb4e0934e
commit
01241483cc
@ -19,10 +19,11 @@ from homeassistant.const import (
|
|||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||||
|
from homeassistant.loader import async_get_integration
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_ALL_UPDATES,
|
CONF_ALL_UPDATES,
|
||||||
@ -40,6 +41,12 @@ from .utils import _async_short_mac, _async_unifi_mac_from_hass
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
async def async_local_user_documentation_url(hass: HomeAssistant) -> str:
|
||||||
|
"""Get the documentation url for creating a local user."""
|
||||||
|
integration = await async_get_integration(hass, DOMAIN)
|
||||||
|
return f"{integration.documentation}#local-user"
|
||||||
|
|
||||||
|
|
||||||
def _host_is_direct_connect(host: str) -> bool:
|
def _host_is_direct_connect(host: str) -> bool:
|
||||||
"""Check if a host is a unifi direct connect domain."""
|
"""Check if a host is a unifi direct connect domain."""
|
||||||
return host.endswith(".ui.direct")
|
return host.endswith(".ui.direct")
|
||||||
@ -139,7 +146,12 @@ class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
user_input = user_input or {}
|
user_input = user_input or {}
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="discovery_confirm",
|
step_id="discovery_confirm",
|
||||||
description_placeholders=placeholders,
|
description_placeholders={
|
||||||
|
**placeholders,
|
||||||
|
"local_user_documentation_url": await async_local_user_documentation_url(
|
||||||
|
self.hass
|
||||||
|
),
|
||||||
|
},
|
||||||
data_schema=vol.Schema(
|
data_schema=vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(
|
vol.Required(
|
||||||
@ -269,6 +281,11 @@ class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
user_input = user_input or {}
|
user_input = user_input or {}
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="user",
|
step_id="user",
|
||||||
|
description_placeholders={
|
||||||
|
"local_user_documentation_url": await async_local_user_documentation_url(
|
||||||
|
self.hass
|
||||||
|
)
|
||||||
|
},
|
||||||
data_schema=vol.Schema(
|
data_schema=vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_HOST, default=user_input.get(CONF_HOST)): str,
|
vol.Required(CONF_HOST, default=user_input.get(CONF_HOST)): str,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"step": {
|
"step": {
|
||||||
"user": {
|
"user": {
|
||||||
"title": "UniFi Protect Setup",
|
"title": "UniFi Protect Setup",
|
||||||
|
"description": "You will need a local user created in your UniFi OS Console to log in with. Ubiquiti Cloud Users will not work. For more information: {local_user_documentation_url}",
|
||||||
"data": {
|
"data": {
|
||||||
"host": "[%key:common::config_flow::data::host%]",
|
"host": "[%key:common::config_flow::data::host%]",
|
||||||
"port": "[%key:common::config_flow::data::port%]",
|
"port": "[%key:common::config_flow::data::port%]",
|
||||||
@ -22,7 +23,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"discovery_confirm": {
|
"discovery_confirm": {
|
||||||
"description": "Do you want to setup {name} ({ip_address})?",
|
"title": "UniFi Protect Discovered",
|
||||||
|
"description": "Do you want to setup {name} ({ip_address})? [%key:component::unifiprotect::config::step::user::description%]",
|
||||||
"data": {
|
"data": {
|
||||||
"username": "[%key:common::config_flow::data::username%]",
|
"username": "[%key:common::config_flow::data::username%]",
|
||||||
"password": "[%key:common::config_flow::data::password%]"
|
"password": "[%key:common::config_flow::data::password%]"
|
||||||
|
@ -7,18 +7,17 @@
|
|||||||
"error": {
|
"error": {
|
||||||
"cannot_connect": "Failed to connect",
|
"cannot_connect": "Failed to connect",
|
||||||
"invalid_auth": "Invalid authentication",
|
"invalid_auth": "Invalid authentication",
|
||||||
"protect_version": "Minimum required version is v1.20.0. Please upgrade UniFi Protect and then retry.",
|
"protect_version": "Minimum required version is v1.20.0. Please upgrade UniFi Protect and then retry."
|
||||||
"unknown": "Unexpected error"
|
|
||||||
},
|
},
|
||||||
"flow_title": "{name} ({ip_address})",
|
"flow_title": "{name} ({ip_address})",
|
||||||
"step": {
|
"step": {
|
||||||
"discovery_confirm": {
|
"discovery_confirm": {
|
||||||
"data": {
|
"data": {
|
||||||
"password": "Password",
|
"password": "Password",
|
||||||
"username": "Username",
|
"username": "Username"
|
||||||
"verify_ssl": "Verify SSL certificate"
|
|
||||||
},
|
},
|
||||||
"description": "Do you want to setup {name} ({ip_address})?"
|
"description": "Do you want to setup {name} ({ip_address})? You will need a local user created in your UniFi OS Console to log in with. Ubiquiti Cloud Users will not work. For more information: {local_user_documentation_url}",
|
||||||
|
"title": "UniFi Protect Discovered"
|
||||||
},
|
},
|
||||||
"reauth_confirm": {
|
"reauth_confirm": {
|
||||||
"data": {
|
"data": {
|
||||||
@ -37,6 +36,7 @@
|
|||||||
"username": "Username",
|
"username": "Username",
|
||||||
"verify_ssl": "Verify SSL certificate"
|
"verify_ssl": "Verify SSL certificate"
|
||||||
},
|
},
|
||||||
|
"description": "You will need a local user created in your UniFi OS Console to log in with. Ubiquiti Cloud Users will not work. For more information: {local_user_documentation_url}",
|
||||||
"title": "UniFi Protect Setup"
|
"title": "UniFi Protect Setup"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user