From 2515e520c1c0fe6e7966193f1a369d7aac224b8c Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 18 Dec 2023 15:30:59 +0100 Subject: [PATCH] Allow step size any for number selector in slider mode (#105978) --- homeassistant/helpers/selector.py | 3 --- tests/helpers/test_selector.py | 7 +------ 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/homeassistant/helpers/selector.py b/homeassistant/helpers/selector.py index f7ceb4ab812..ab22877f906 100644 --- a/homeassistant/helpers/selector.py +++ b/homeassistant/helpers/selector.py @@ -951,9 +951,6 @@ def validate_slider(data: Any) -> Any: if "min" not in data or "max" not in data: raise vol.Invalid("min and max are required in slider mode") - if "step" in data and data["step"] == "any": - raise vol.Invalid("step 'any' is not allowed in slider mode") - return data diff --git a/tests/helpers/test_selector.py b/tests/helpers/test_selector.py index c4ad244620b..e925b425f96 100644 --- a/tests/helpers/test_selector.py +++ b/tests/helpers/test_selector.py @@ -396,6 +396,7 @@ def test_assist_pipeline_selector_schema( ({"min": 10, "max": 1000, "mode": "slider", "step": 0.5}, (), ()), ({"mode": "box"}, (10,), ()), ({"mode": "box", "step": "any"}, (), ()), + ({"mode": "slider", "min": 0, "max": 1, "step": "any"}, (), ()), ), ) def test_number_selector_schema(schema, valid_selections, invalid_selections) -> None: @@ -408,12 +409,6 @@ def test_number_selector_schema(schema, valid_selections, invalid_selections) -> ( {}, # Must have mandatory fields {"mode": "slider"}, # Must have min+max in slider mode - { - "mode": "slider", - "min": 0, - "max": 1, - "step": "any", # Can't combine slider with step any - }, ), ) def test_number_selector_schema_error(schema) -> None: