mirror of
https://github.com/home-assistant/core.git
synced 2025-08-01 19:55:10 +02:00
Allow number selector selection to be None
This commit is contained in:
@@ -207,8 +207,11 @@ class NumberSelector(Selector):
|
|||||||
has_min_max_if_slider,
|
has_min_max_if_slider,
|
||||||
)
|
)
|
||||||
|
|
||||||
def __call__(self, data: Any) -> float:
|
def __call__(self, data: Any) -> float | None:
|
||||||
"""Validate the passed selection."""
|
"""Validate the passed selection."""
|
||||||
|
if data is None:
|
||||||
|
return data
|
||||||
|
|
||||||
value: float = vol.Coerce(float)(data)
|
value: float = vol.Coerce(float)(data)
|
||||||
|
|
||||||
if "min" in self.config and value < self.config["min"]:
|
if "min" in self.config and value < self.config["min"]:
|
||||||
|
@@ -208,7 +208,8 @@ def test_area_selector_schema(schema, valid_selections, invalid_selections):
|
|||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
({"min": 10, "max": 1000, "mode": "slider", "step": 0.5}, (), ()),
|
({"min": 10, "max": 1000, "mode": "slider", "step": 0.5}, (), ()),
|
||||||
({"mode": "box"}, (10,), ()),
|
({"mode": "box"}, (10, None), ("cat")),
|
||||||
|
({"mode": "slider", "min": -100, "max": 100}, (10, None), ("cat")),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_number_selector_schema(schema, valid_selections, invalid_selections):
|
def test_number_selector_schema(schema, valid_selections, invalid_selections):
|
||||||
|
Reference in New Issue
Block a user