Add week period to recorder statistics api (#80784)

* add week period to get statistics api

* add test
This commit is contained in:
Michael 2022-10-25 20:07:28 +02:00 committed by GitHub
parent c197e1765a
commit 8175dab7ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 175 additions and 5 deletions

View file

@ -62,7 +62,7 @@ def _ws_get_statistics_during_period(
start_time: dt,
end_time: dt | None,
statistic_ids: list[str] | None,
period: Literal["5minute", "day", "hour", "month"],
period: Literal["5minute", "day", "hour", "week", "month"],
units: dict[str, str],
) -> str:
"""Fetch statistics and convert them to json in the executor."""
@ -118,7 +118,7 @@ async def ws_handle_get_statistics_during_period(
vol.Required("start_time"): str,
vol.Optional("end_time"): str,
vol.Optional("statistic_ids"): [str],
vol.Required("period"): vol.Any("5minute", "hour", "day", "month"),
vol.Required("period"): vol.Any("5minute", "hour", "day", "week", "month"),
vol.Optional("units"): vol.Schema(
{
vol.Optional("distance"): vol.In(DistanceConverter.VALID_UNITS),