mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 02:03:27 +01:00
Fix default value of DurationSelector allow_negative (#162924)
This commit is contained in:
committed by
GitHub
parent
fcdeaead6f
commit
ea281e14bf
@@ -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)
|
||||
|
||||
@@ -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, {}),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user