Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes references to croniter from utility_meter #132364

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions homeassistant/components/utility_meter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Support for tracking consumption over given periods of time."""

from datetime import timedelta
from datetime import datetime, timedelta
import logging

from croniter import croniter
from cronsim import CronSim, CronSimError
import voluptuous as vol

from homeassistant.components.select import DOMAIN as SELECT_DOMAIN
Expand Down Expand Up @@ -47,9 +47,12 @@

def validate_cron_pattern(pattern):
"""Check that the pattern is well-formed."""
if croniter.is_valid(pattern):
return pattern
raise vol.Invalid("Invalid pattern")
try:
CronSim(pattern, datetime(2020, 1, 1)) # any date will do
except CronSimError as err:
_LOGGER.error("Invalid cron pattern %s: %s", pattern, err)
raise vol.Invalid("Invalid pattern") from err
return pattern


def period_or_cron(config):
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/utility_meter/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"documentation": "https://www.home-assistant.io/integrations/utility_meter",
"integration_type": "helper",
"iot_class": "local_push",
"loggers": ["croniter"],
"quality_scale": "internal",
"requirements": ["cronsim==2.6"]
}