From d82899ed2fa3bd6f02c20557061cc18de06d8e41 Mon Sep 17 00:00:00 2001 From: Vincent Le Bourlot Date: Mon, 7 Feb 2022 16:53:05 +0100 Subject: [PATCH] Add title placeholders to overkiz discovery (#65506) * add gateway_id to the config flow context name. * obfuscate gateway_id. * replace const with homeassistant.const. * Remove obfuscation of gateway_id. * fix style. * Add translatable title according to comments * Update homeassistant/components/overkiz/strings.json Co-authored-by: J. Nick Koston --- homeassistant/components/overkiz/config_flow.py | 10 +++++----- homeassistant/components/overkiz/strings.json | 1 + homeassistant/components/overkiz/translations/en.json | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/overkiz/config_flow.py b/homeassistant/components/overkiz/config_flow.py index 1a0a94198cc..2f8dcc18921 100644 --- a/homeassistant/components/overkiz/config_flow.py +++ b/homeassistant/components/overkiz/config_flow.py @@ -128,11 +128,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): gateway_id = hostname[8:22] LOGGER.debug("DHCP discovery detected gateway %s", obfuscate_id(gateway_id)) - - await self.async_set_unique_id(gateway_id) - self._abort_if_unique_id_configured() - - return await self.async_step_user() + return await self._process_discovery(gateway_id) async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo @@ -144,9 +140,13 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): gateway_id = properties["gateway_pin"] LOGGER.debug("ZeroConf discovery detected gateway %s", obfuscate_id(gateway_id)) + return await self._process_discovery(gateway_id) + async def _process_discovery(self, gateway_id: str) -> FlowResult: + """Handle discovery of a gateway.""" await self.async_set_unique_id(gateway_id) self._abort_if_unique_id_configured() + self.context["title_placeholders"] = {"gateway_id": gateway_id} return await self.async_step_user() diff --git a/homeassistant/components/overkiz/strings.json b/homeassistant/components/overkiz/strings.json index 2bef16ec2dd..87487d53c66 100644 --- a/homeassistant/components/overkiz/strings.json +++ b/homeassistant/components/overkiz/strings.json @@ -1,5 +1,6 @@ { "config": { + "flow_title": "Gateway: {gateway_id}", "step": { "user": { "description": "The Overkiz platform is used by various vendors like Somfy (Connexoon / TaHoma), Hitachi (Hi Kumo), Rexel (Energeasy Connect) and Atlantic (Cozytouch). Enter your application credentials and select your hub.", diff --git a/homeassistant/components/overkiz/translations/en.json b/homeassistant/components/overkiz/translations/en.json index 42380904583..c9551aa555c 100644 --- a/homeassistant/components/overkiz/translations/en.json +++ b/homeassistant/components/overkiz/translations/en.json @@ -12,6 +12,7 @@ "too_many_requests": "Too many requests, try again later", "unknown": "Unexpected error" }, + "flow_title": "Gateway: {gateway_id}", "step": { "user": { "data": {