mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove name option from config_flow for P1 Monitor (#77046)
This commit is contained in:
parent
3a3f41f3df
commit
0795d28ed5
@ -7,9 +7,10 @@ from p1monitor import P1Monitor, P1MonitorError
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
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.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
from homeassistant.helpers.selector import TextSelector
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ class P1MonitorFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
else:
|
else:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=user_input[CONF_NAME],
|
title="P1 Monitor",
|
||||||
data={
|
data={
|
||||||
CONF_HOST: user_input[CONF_HOST],
|
CONF_HOST: user_input[CONF_HOST],
|
||||||
},
|
},
|
||||||
@ -47,10 +48,7 @@ class P1MonitorFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
step_id="user",
|
step_id="user",
|
||||||
data_schema=vol.Schema(
|
data_schema=vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(
|
vol.Required(CONF_HOST): TextSelector(),
|
||||||
CONF_NAME, default=self.hass.config.location_name
|
|
||||||
): str,
|
|
||||||
vol.Required(CONF_HOST): str,
|
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
errors=errors,
|
errors=errors,
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
"user": {
|
"user": {
|
||||||
"description": "Set up P1 Monitor to integrate with Home Assistant.",
|
"description": "Set up P1 Monitor to integrate with Home Assistant.",
|
||||||
"data": {
|
"data": {
|
||||||
"host": "[%key:common::config_flow::data::host%]",
|
"host": "[%key:common::config_flow::data::host%]"
|
||||||
"name": "[%key:common::config_flow::data::name%]"
|
},
|
||||||
|
"data_description": {
|
||||||
|
"host": "The IP address or hostname of your P1 Monitor installation."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -6,8 +6,10 @@
|
|||||||
"step": {
|
"step": {
|
||||||
"user": {
|
"user": {
|
||||||
"data": {
|
"data": {
|
||||||
"host": "Host",
|
"host": "Host"
|
||||||
"name": "Name"
|
},
|
||||||
|
"data_description": {
|
||||||
|
"host": "The IP address or hostname of your P1 Monitor installation."
|
||||||
},
|
},
|
||||||
"description": "Set up P1 Monitor to integrate with Home Assistant."
|
"description": "Set up P1 Monitor to integrate with Home Assistant."
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ from p1monitor import P1MonitorError
|
|||||||
|
|
||||||
from homeassistant.components.p1_monitor.const import DOMAIN
|
from homeassistant.components.p1_monitor.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
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.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
@ -27,11 +27,11 @@ async def test_full_user_flow(hass: HomeAssistant) -> None:
|
|||||||
) as mock_setup_entry:
|
) as mock_setup_entry:
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
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("type") == FlowResultType.CREATE_ENTRY
|
||||||
assert result2.get("title") == "Name"
|
assert result2.get("title") == "P1 Monitor"
|
||||||
assert result2.get("data") == {CONF_HOST: "example.com"}
|
assert result2.get("data") == {CONF_HOST: "example.com"}
|
||||||
|
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
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(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": SOURCE_USER},
|
context={"source": SOURCE_USER},
|
||||||
data={CONF_NAME: "Name", CONF_HOST: "example.com"},
|
data={CONF_HOST: "example.com"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") == FlowResultType.FORM
|
||||||
|
Loading…
x
Reference in New Issue
Block a user