1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00

Remove name option from config_flow for P1 Monitor (#77046)

This commit is contained in:
Klaas Schoute 2022-08-20 08:03:43 +02:00 committed by GitHub
parent 3a3f41f3df
commit 0795d28ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 14 deletions

View File

@ -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,

View File

@ -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."
}
}
},

View File

@ -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."
}

View File

@ -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