From 1746677b61c99ec55bb4ab1a7bdb0eb7660134cf Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 28 Mar 2022 09:28:32 +0200 Subject: [PATCH] Clarify duration selector (#68731) --- homeassistant/helpers/selector.py | 2 ++ tests/helpers/test_selector.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/homeassistant/helpers/selector.py b/homeassistant/helpers/selector.py index 764f8ed49af..9577381d92b 100644 --- a/homeassistant/helpers/selector.py +++ b/homeassistant/helpers/selector.py @@ -277,6 +277,8 @@ class DurationSelector(Selector): CONFIG_SCHEMA = vol.Schema( { + # Enable day field in frontend. A selection with `days` set is allowed + # even if `enable_day` is not set vol.Optional("enable_day"): cv.boolean, } ) diff --git a/tests/helpers/test_selector.py b/tests/helpers/test_selector.py index f1d7c83f211..9e68af05487 100644 --- a/tests/helpers/test_selector.py +++ b/tests/helpers/test_selector.py @@ -406,12 +406,15 @@ def test_attribute_selector_schema(schema, valid_selections, invalid_selections) ( ( {}, - ({"seconds": 10},), + ( + {"seconds": 10}, + {"days": 10}, # Days is allowed also if `enable_day` is not set + ), (None, {}), ), ( {"enable_day": True}, - ({"seconds": 10},), + ({"seconds": 10}, {"days": 10}), (None, {}), ), ),