Reolink improve config flow login (#90036)
This commit is contained in:
parent
8dbcbd156a
commit
d427c35c87
3 changed files with 16 additions and 11 deletions
|
@ -108,7 +108,10 @@ class ReolinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors = {}
|
errors = {}
|
||||||
placeholders = {"error": ""}
|
placeholders = {
|
||||||
|
"error": "",
|
||||||
|
"troubleshooting_link": "https://www.home-assistant.io/integrations/reolink/#troubleshooting",
|
||||||
|
}
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
if CONF_HOST not in user_input:
|
if CONF_HOST not in user_input:
|
||||||
|
|
|
@ -82,9 +82,15 @@ class ReolinkHost:
|
||||||
f"'{self._api.user_level}', only admin users can change camera settings"
|
f"'{self._api.user_level}', only admin users can change camera settings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
enable_rtsp = None
|
||||||
enable_onvif = None
|
enable_onvif = None
|
||||||
enable_rtmp = None
|
enable_rtmp = None
|
||||||
enable_rtsp = None
|
|
||||||
|
if not self._api.rtsp_enabled:
|
||||||
|
_LOGGER.debug(
|
||||||
|
"RTSP is disabled on %s, trying to enable it", self._api.nvr_name
|
||||||
|
)
|
||||||
|
enable_rtsp = True
|
||||||
|
|
||||||
if not self._api.onvif_enabled:
|
if not self._api.onvif_enabled:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
|
@ -97,11 +103,6 @@ class ReolinkHost:
|
||||||
"RTMP is disabled on %s, trying to enable it", self._api.nvr_name
|
"RTMP is disabled on %s, trying to enable it", self._api.nvr_name
|
||||||
)
|
)
|
||||||
enable_rtmp = True
|
enable_rtmp = True
|
||||||
elif not self._api.rtsp_enabled and self._api.protocol == "rtsp":
|
|
||||||
_LOGGER.debug(
|
|
||||||
"RTSP is disabled on %s, trying to enable it", self._api.nvr_name
|
|
||||||
)
|
|
||||||
enable_rtsp = True
|
|
||||||
|
|
||||||
if enable_onvif or enable_rtmp or enable_rtsp:
|
if enable_onvif or enable_rtmp or enable_rtsp:
|
||||||
try:
|
try:
|
||||||
|
@ -112,13 +113,14 @@ class ReolinkHost:
|
||||||
)
|
)
|
||||||
except ReolinkError:
|
except ReolinkError:
|
||||||
ports = ""
|
ports = ""
|
||||||
|
if enable_rtsp:
|
||||||
|
ports += "RTSP "
|
||||||
|
|
||||||
if enable_onvif:
|
if enable_onvif:
|
||||||
ports += "ONVIF "
|
ports += "ONVIF "
|
||||||
|
|
||||||
if enable_rtmp:
|
if enable_rtmp:
|
||||||
ports += "RTMP "
|
ports += "RTMP "
|
||||||
elif enable_rtsp:
|
|
||||||
ports += "RTSP "
|
|
||||||
|
|
||||||
ir.async_create_issue(
|
ir.async_create_issue(
|
||||||
self._hass,
|
self._hass,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"flow_title": "{hostname} ({ip_address})",
|
"flow_title": "{hostname} ({ip_address})",
|
||||||
"step": {
|
"step": {
|
||||||
"user": {
|
"user": {
|
||||||
"description": "{error}",
|
"description": "See the [troubleshooting steps]({troubleshooting_link}) if you encounter problems. {error}",
|
||||||
"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%]",
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"api_error": "API error occurred",
|
"api_error": "API error occurred",
|
||||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%], check the IP address of the camera and see the troubleshooting steps in the documentation",
|
||||||
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||||
"not_admin": "User needs to be admin, user ''{username}'' has authorisation level ''{userlevel}''",
|
"not_admin": "User needs to be admin, user ''{username}'' has authorisation level ''{userlevel}''",
|
||||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue