From 4e74d14beb5cca93e04aaeb22db30295194d808f Mon Sep 17 00:00:00 2001 From: Duco Sebel <74970928+DCSBL@users.noreply.github.com> Date: Thu, 2 Jan 2025 19:34:51 +0100 Subject: [PATCH] Include host in Peblar EV-Charger discovery setup description (#133954) Co-authored-by: Franck Nijhof --- .../components/peblar/config_flow.py | 21 ++++++++++++++----- homeassistant/components/peblar/strings.json | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/peblar/config_flow.py b/homeassistant/components/peblar/config_flow.py index 29bf456b7ea..24248355f72 100644 --- a/homeassistant/components/peblar/config_flow.py +++ b/homeassistant/components/peblar/config_flow.py @@ -27,7 +27,7 @@ class PeblarFlowHandler(ConfigFlow, domain=DOMAIN): VERSION = 1 - _host: str + _discovery_info: zeroconf.ZeroconfServiceInfo async def async_step_user( self, user_input: dict[str, Any] | None = None @@ -137,8 +137,15 @@ class PeblarFlowHandler(ConfigFlow, domain=DOMAIN): await self.async_set_unique_id(sn) self._abort_if_unique_id_configured(updates={CONF_HOST: discovery_info.host}) - self._host = discovery_info.host - self.context.update({"configuration_url": f"http://{discovery_info.host}"}) + self._discovery_info = discovery_info + self.context.update( + { + "title_placeholders": { + "name": discovery_info.name.replace("._http._tcp.local.", "") + }, + "configuration_url": f"http://{discovery_info.host}", + }, + ) return await self.async_step_zeroconf_confirm() async def async_step_zeroconf_confirm( @@ -149,7 +156,7 @@ class PeblarFlowHandler(ConfigFlow, domain=DOMAIN): if user_input is not None: peblar = Peblar( - host=self._host, + host=self._discovery_info.host, session=async_create_clientsession( self.hass, cookie_jar=CookieJar(unsafe=True) ), @@ -165,7 +172,7 @@ class PeblarFlowHandler(ConfigFlow, domain=DOMAIN): return self.async_create_entry( title="Peblar", data={ - CONF_HOST: self._host, + CONF_HOST: self._discovery_info.host, CONF_PASSWORD: user_input[CONF_PASSWORD], }, ) @@ -179,6 +186,10 @@ class PeblarFlowHandler(ConfigFlow, domain=DOMAIN): ), } ), + description_placeholders={ + "hostname": self._discovery_info.name.replace("._http._tcp.local.", ""), + "host": self._discovery_info.host, + }, errors=errors, ) diff --git a/homeassistant/components/peblar/strings.json b/homeassistant/components/peblar/strings.json index f6a228ca236..3fcd7a14664 100644 --- a/homeassistant/components/peblar/strings.json +++ b/homeassistant/components/peblar/strings.json @@ -51,7 +51,7 @@ "data_description": { "password": "[%key:component::peblar::config::step::user::data_description::password%]" }, - "description": "Set up your Peblar EV charger to integrate with Home Assistant.\n\nTo do so, you will need the password you use to log into the Peblar EV charger' web interface.\n\nHome Assistant will automatically configure your Peblar EV charger for use with Home Assistant." + "description": "Set up your Peblar EV charger {hostname}, on IP address {host}, to integrate with Home Assistant\n\nTo do so, you will need the password you use to log into the Peblar EV charger' web interface.\n\nHome Assistant will automatically configure your Peblar EV charger for use with Home Assistant." } } },