Force int value on port in P1Monitor (#130084)

pull/130156/head
Klaas Schoute 2024-11-08 16:15:57 +01:00 committed by Franck Nijhof
parent 29620ef977
commit 0206c149cf
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 8 additions and 4 deletions

View File

@ -57,10 +57,13 @@ class P1MonitorFlowHandler(ConfigFlow, domain=DOMAIN):
data_schema=vol.Schema(
{
vol.Required(CONF_HOST): TextSelector(),
vol.Required(CONF_PORT, default=80): NumberSelector(
NumberSelectorConfig(
mode=NumberSelectorMode.BOX,
)
vol.Required(CONF_PORT, default=80): vol.All(
NumberSelector(
NumberSelectorConfig(
min=1, max=65535, mode=NumberSelectorMode.BOX
),
),
vol.Coerce(int),
),
}
),

View File

@ -36,6 +36,7 @@ async def test_full_user_flow(hass: HomeAssistant) -> None:
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "P1 Monitor"
assert result2.get("data") == {CONF_HOST: "example.com", CONF_PORT: 80}
assert isinstance(result2["data"][CONF_PORT], int)
assert len(mock_setup_entry.mock_calls) == 1
assert len(mock_p1monitor.mock_calls) == 1