Add enable_millisecond to duration selector (#122821)
* Add enable_milliseconds to duration selector. * One more test
This commit is contained in:
parent
97de1c2b66
commit
3df78043c0
2 changed files with 6 additions and 2 deletions
|
@ -725,6 +725,7 @@ class DurationSelectorConfig(TypedDict, total=False):
|
|||
"""Class to represent a duration selector config."""
|
||||
|
||||
enable_day: bool
|
||||
enable_millisecond: bool
|
||||
allow_negative: bool
|
||||
|
||||
|
||||
|
@ -739,6 +740,8 @@ class DurationSelector(Selector[DurationSelectorConfig]):
|
|||
# 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,
|
||||
# Enable millisecond field in frontend.
|
||||
vol.Optional("enable_millisecond"): cv.boolean,
|
||||
# Allow negative durations. Will default to False in HA Core 2025.6.0.
|
||||
vol.Optional("allow_negative"): cv.boolean,
|
||||
}
|
||||
|
|
|
@ -739,12 +739,13 @@ def test_attribute_selector_schema(
|
|||
(
|
||||
{"seconds": 10},
|
||||
{"days": 10}, # Days is allowed also if `enable_day` is not set
|
||||
{"milliseconds": 500},
|
||||
),
|
||||
(None, {}),
|
||||
),
|
||||
(
|
||||
{"enable_day": True},
|
||||
({"seconds": 10}, {"days": 10}),
|
||||
{"enable_day": True, "enable_millisecond": True},
|
||||
({"seconds": 10}, {"days": 10}, {"milliseconds": 500}),
|
||||
(None, {}),
|
||||
),
|
||||
(
|
||||
|
|
Loading…
Add table
Reference in a new issue