coerce number selector values to int (#69059)

pull/66208/head
Matthias Alphart 2022-04-01 10:07:13 +02:00 committed by GitHub
parent 4a921ac67f
commit 2733600755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 10 deletions

View File

@ -65,7 +65,10 @@ CONF_KNX_LABEL_TUNNELING_UDP_ROUTE_BACK: Final = "UDP with route back / NAT mode
_IA_SELECTOR = selector.selector({"text": {}}) _IA_SELECTOR = selector.selector({"text": {}})
_IP_SELECTOR = selector.selector({"text": {}}) _IP_SELECTOR = selector.selector({"text": {}})
_PORT_SELECTOR = selector.selector({"number": {"min": 1, "max": 65535, "mode": "box"}}) _PORT_SELECTOR = vol.All(
selector.selector({"number": {"min": 1, "max": 65535, "mode": "box"}}),
vol.Coerce(int),
)
class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@ -246,8 +249,9 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
) )
fields = { fields = {
vol.Required(CONF_KNX_SECURE_USER_ID, default=2): selector.selector( vol.Required(CONF_KNX_SECURE_USER_ID, default=2): vol.All(
{"number": {"min": 1, "max": 127, "mode": "box"}} selector.selector({"number": {"min": 1, "max": 127, "mode": "box"}}),
vol.Coerce(int),
), ),
vol.Required(CONF_KNX_SECURE_USER_PASSWORD): selector.selector( vol.Required(CONF_KNX_SECURE_USER_PASSWORD): selector.selector(
{"text": {"type": "password"}} {"text": {"type": "password"}}
@ -421,7 +425,8 @@ class KNXOptionsFlowHandler(OptionsFlow):
CONF_KNX_DEFAULT_RATE_LIMIT, CONF_KNX_DEFAULT_RATE_LIMIT,
), ),
) )
] = selector.selector( ] = vol.All(
selector.selector(
{ {
"number": { "number": {
"min": 1, "min": 1,
@ -429,6 +434,8 @@ class KNXOptionsFlowHandler(OptionsFlow):
"mode": "box", "mode": "box",
} }
} }
),
vol.Coerce(int),
) )
return self.async_show_form( return self.async_show_form(