Skip to content

Commit

Permalink
Removes references to croniter from utility_meter (#132364)
Browse files Browse the repository at this point in the history
remove croniter
  • Loading branch information
dgomes authored Dec 5, 2024
1 parent 52e6afd commit 7de9e9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
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"]
}

0 comments on commit 7de9e9d

Please sign in to comment.