Skip to content

Commit

Permalink
Include host in Peblar EV-Charger discovery setup description (#133954)
Browse files Browse the repository at this point in the history
Co-authored-by: Franck Nijhof <[email protected]>
  • Loading branch information
DCSBL and frenck authored Jan 2, 2025
1 parent 309b7eb commit 4e74d14
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions homeassistant/components/peblar/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -137,8 +137,15 @@ async def async_step_zeroconf(
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(
Expand All @@ -149,7 +156,7 @@ async def async_step_zeroconf_confirm(

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)
),
Expand All @@ -165,7 +172,7 @@ async def async_step_zeroconf_confirm(
return self.async_create_entry(
title="Peblar",
data={
CONF_HOST: self._host,
CONF_HOST: self._discovery_info.host,
CONF_PASSWORD: user_input[CONF_PASSWORD],
},
)
Expand All @@ -179,6 +186,10 @@ async def async_step_zeroconf_confirm(
),
}
),
description_placeholders={
"hostname": self._discovery_info.name.replace("._http._tcp.local.", ""),
"host": self._discovery_info.host,
},
errors=errors,
)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/peblar/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
},
Expand Down

0 comments on commit 4e74d14

Please sign in to comment.