From 0795d28ed5d3b981fdabc884ac2d6e1bdd10ae98 Mon Sep 17 00:00:00 2001 From: Klaas Schoute Date: Sat, 20 Aug 2022 08:03:43 +0200 Subject: [PATCH] Remove name option from config_flow for P1 Monitor (#77046) --- homeassistant/components/p1_monitor/config_flow.py | 10 ++++------ homeassistant/components/p1_monitor/strings.json | 6 ++++-- .../components/p1_monitor/translations/en.json | 6 ++++-- tests/components/p1_monitor/test_config_flow.py | 8 ++++---- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/p1_monitor/config_flow.py b/homeassistant/components/p1_monitor/config_flow.py index 9e9d695f5e9..00b035aba7f 100644 --- a/homeassistant/components/p1_monitor/config_flow.py +++ b/homeassistant/components/p1_monitor/config_flow.py @@ -7,9 +7,10 @@ from p1monitor import P1Monitor, P1MonitorError import voluptuous as vol from homeassistant.config_entries import ConfigFlow -from homeassistant.const import CONF_HOST, CONF_NAME +from homeassistant.const import CONF_HOST from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession +from homeassistant.helpers.selector import TextSelector from .const import DOMAIN @@ -37,7 +38,7 @@ class P1MonitorFlowHandler(ConfigFlow, domain=DOMAIN): errors["base"] = "cannot_connect" else: return self.async_create_entry( - title=user_input[CONF_NAME], + title="P1 Monitor", data={ CONF_HOST: user_input[CONF_HOST], }, @@ -47,10 +48,7 @@ class P1MonitorFlowHandler(ConfigFlow, domain=DOMAIN): step_id="user", data_schema=vol.Schema( { - vol.Optional( - CONF_NAME, default=self.hass.config.location_name - ): str, - vol.Required(CONF_HOST): str, + vol.Required(CONF_HOST): TextSelector(), } ), errors=errors, diff --git a/homeassistant/components/p1_monitor/strings.json b/homeassistant/components/p1_monitor/strings.json index b088bf7adce..0c745554e9d 100644 --- a/homeassistant/components/p1_monitor/strings.json +++ b/homeassistant/components/p1_monitor/strings.json @@ -4,8 +4,10 @@ "user": { "description": "Set up P1 Monitor to integrate with Home Assistant.", "data": { - "host": "[%key:common::config_flow::data::host%]", - "name": "[%key:common::config_flow::data::name%]" + "host": "[%key:common::config_flow::data::host%]" + }, + "data_description": { + "host": "The IP address or hostname of your P1 Monitor installation." } } }, diff --git a/homeassistant/components/p1_monitor/translations/en.json b/homeassistant/components/p1_monitor/translations/en.json index 4bd61c19bdc..394b6c0767b 100644 --- a/homeassistant/components/p1_monitor/translations/en.json +++ b/homeassistant/components/p1_monitor/translations/en.json @@ -6,8 +6,10 @@ "step": { "user": { "data": { - "host": "Host", - "name": "Name" + "host": "Host" + }, + "data_description": { + "host": "The IP address or hostname of your P1 Monitor installation." }, "description": "Set up P1 Monitor to integrate with Home Assistant." } diff --git a/tests/components/p1_monitor/test_config_flow.py b/tests/components/p1_monitor/test_config_flow.py index 13541e782b4..d7d0608e5b3 100644 --- a/tests/components/p1_monitor/test_config_flow.py +++ b/tests/components/p1_monitor/test_config_flow.py @@ -5,7 +5,7 @@ from p1monitor import P1MonitorError from homeassistant.components.p1_monitor.const import DOMAIN from homeassistant.config_entries import SOURCE_USER -from homeassistant.const import CONF_HOST, CONF_NAME +from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -27,11 +27,11 @@ async def test_full_user_flow(hass: HomeAssistant) -> None: ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], - user_input={CONF_NAME: "Name", CONF_HOST: "example.com"}, + user_input={CONF_HOST: "example.com"}, ) assert result2.get("type") == FlowResultType.CREATE_ENTRY - assert result2.get("title") == "Name" + assert result2.get("title") == "P1 Monitor" assert result2.get("data") == {CONF_HOST: "example.com"} assert len(mock_setup_entry.mock_calls) == 1 @@ -47,7 +47,7 @@ async def test_api_error(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, - data={CONF_NAME: "Name", CONF_HOST: "example.com"}, + data={CONF_HOST: "example.com"}, ) assert result.get("type") == FlowResultType.FORM