1 """Validation utility functions for ecobee services."""
3 from datetime
import date, datetime, timedelta
5 import voluptuous
as vol
9 """Validate a date_string as valid for the ecobee API."""
11 datetime.strptime(date_string,
"%Y-%m-%d")
12 except ValueError
as err:
13 raise vol.Invalid(
"Date does not match ecobee date format YYYY-MM-DD")
from err
18 """Validate a time_string as valid for the ecobee API."""
20 datetime.strptime(time_string,
"%H:%M:%S")
21 except ValueError
as err:
23 "Time does not match ecobee 24-hour time format HH:MM:SS"
29 """Determine if the given start and end dates from the ecobee API represent an indefinite hold.
31 This is not documented in the API, so a rough heuristic is used where a hold over 1 year is considered indefinite.
33 return date.fromisoformat(end_date_string) - date.fromisoformat(
bool is_indefinite_hold(str start_date_string, str end_date_string)
def ecobee_time(time_string)
def ecobee_date(date_string)