From d427c35c871ff3e4be4adbc803d7bfc9677b624c Mon Sep 17 00:00:00 2001 From: starkillerOG Date: Wed, 29 Mar 2023 14:41:38 +0200 Subject: [PATCH] Reolink improve config flow login (#90036) --- .../components/reolink/config_flow.py | 5 ++++- homeassistant/components/reolink/host.py | 18 ++++++++++-------- homeassistant/components/reolink/strings.json | 4 ++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/reolink/config_flow.py b/homeassistant/components/reolink/config_flow.py index 15f3dfa613e..a29871f28dc 100644 --- a/homeassistant/components/reolink/config_flow.py +++ b/homeassistant/components/reolink/config_flow.py @@ -108,7 +108,10 @@ class ReolinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) -> FlowResult: """Handle the initial step.""" errors = {} - placeholders = {"error": ""} + placeholders = { + "error": "", + "troubleshooting_link": "https://www.home-assistant.io/integrations/reolink/#troubleshooting", + } if user_input is not None: if CONF_HOST not in user_input: diff --git a/homeassistant/components/reolink/host.py b/homeassistant/components/reolink/host.py index 1c0f97b6a2d..f7810746481 100644 --- a/homeassistant/components/reolink/host.py +++ b/homeassistant/components/reolink/host.py @@ -82,9 +82,15 @@ class ReolinkHost: f"'{self._api.user_level}', only admin users can change camera settings" ) + enable_rtsp = None enable_onvif = 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: _LOGGER.debug( @@ -97,11 +103,6 @@ class ReolinkHost: "RTMP is disabled on %s, trying to enable it", self._api.nvr_name ) 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: try: @@ -112,13 +113,14 @@ class ReolinkHost: ) except ReolinkError: ports = "" + if enable_rtsp: + ports += "RTSP " + if enable_onvif: ports += "ONVIF " if enable_rtmp: ports += "RTMP " - elif enable_rtsp: - ports += "RTSP " ir.async_create_issue( self._hass, diff --git a/homeassistant/components/reolink/strings.json b/homeassistant/components/reolink/strings.json index 50c561530e5..c36001e0377 100644 --- a/homeassistant/components/reolink/strings.json +++ b/homeassistant/components/reolink/strings.json @@ -3,7 +3,7 @@ "flow_title": "{hostname} ({ip_address})", "step": { "user": { - "description": "{error}", + "description": "See the [troubleshooting steps]({troubleshooting_link}) if you encounter problems. {error}", "data": { "host": "[%key:common::config_flow::data::host%]", "port": "[%key:common::config_flow::data::port%]", @@ -19,7 +19,7 @@ }, "error": { "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%]", "not_admin": "User needs to be admin, user ''{username}'' has authorisation level ''{userlevel}''", "unknown": "[%key:common::config_flow::error::unknown%]"