Fix default value of DurationSelector allow_negative (#162924)

This commit is contained in:
Kevin Stillhammer
2026-02-15 10:42:57 +01:00
committed by GitHub
parent fcdeaead6f
commit ea281e14bf
2 changed files with 7 additions and 7 deletions

View File

@@ -855,7 +855,7 @@ class DurationSelector(Selector[DurationSelectorConfig]):
vol.Optional("enable_day"): cv.boolean,
# Enable millisecond field in frontend.
vol.Optional("enable_millisecond"): cv.boolean,
# Allow negative durations. Will default to False in HA Core 2025.6.0.
# Allow negative durations.
vol.Optional("allow_negative"): cv.boolean,
}
)
@@ -866,7 +866,7 @@ class DurationSelector(Selector[DurationSelectorConfig]):
def __call__(self, data: Any) -> dict[str, float]:
"""Validate the passed selection."""
if self.config.get("allow_negative", True):
if self.config.get("allow_negative", False):
cv.time_period_dict(data)
else:
cv.positive_time_period_dict(data)

View File

@@ -1308,17 +1308,17 @@ def test_attribute_selector_schema(
{"days": 10}, # Days is allowed also if `enable_day` is not set
{"milliseconds": 500},
),
(None, {}),
(None, {}, {"seconds": -1}),
),
(
{"enable_day": True, "enable_millisecond": True},
({"seconds": 10}, {"days": 10}, {"milliseconds": 500}),
(None, {}),
(None, {}, {"seconds": -1}),
),
(
{"allow_negative": False},
({"seconds": 10}, {"days": 10}),
(None, {}, {"seconds": -1}),
{"allow_negative": True},
({"seconds": 10}, {"seconds": -1}),
(None, {}),
),
],
)