Check that time_pattern interval matcher is not zero (#142630)

Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Brian Choromanski 2025-04-15 09:50:11 -04:00 committed by GitHub
parent 2074c7fcee
commit 595508bf7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 0 deletions

View File

@ -37,6 +37,8 @@ class TimePattern:
if isinstance(value, str) and value.startswith("/"):
number = int(value[1:])
if number == 0:
raise vol.Invalid(f"must be a value between 1 and {self.maximum}")
else:
value = number = int(value)

View File

@ -365,6 +365,7 @@ async def test_invalid_schemas() -> None:
{"platform": "time_pattern", "minutes": "/"},
{"platform": "time_pattern", "minutes": "*/5"},
{"platform": "time_pattern", "minutes": "/90"},
{"platform": "time_pattern", "hours": "/0", "minutes": 10},
{"platform": "time_pattern", "hours": 12, "minutes": 0, "seconds": 100},
)