Add support for custom weekly backup schedule (#136079)

* Add support for custom weekly backup schedule

* Rename the new flag to custom_days

* Make the store change backwards compatible

* Improve comments
This commit is contained in:
Erik Montnemery
2025-01-21 08:27:41 +01:00
committed by GitHub
parent 79a43b8a50
commit fb4df00e3c
6 changed files with 831 additions and 160 deletions

View File

@@ -8,7 +8,7 @@ from homeassistant.components import websocket_api
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv
from .config import ScheduleState
from .config import Day, ScheduleRecurrence
from .const import DATA_MANAGER, LOGGER
from .manager import (
DecryptOnDowloadNotSupported,
@@ -320,13 +320,17 @@ async def handle_config_info(
) -> None:
"""Send the stored backup config."""
manager = hass.data[DATA_MANAGER]
config = manager.config.data.to_dict()
# Remove state from schedule, it's not needed in the frontend
# mypy doesn't like deleting from TypedDict, ignore it
del config["schedule"]["state"] # type: ignore[misc]
connection.send_result(
msg["id"],
{
"config": manager.config.data.to_dict()
"config": config
| {
"next_automatic_backup": manager.config.data.schedule.next_automatic_backup
},
}
},
)
@@ -358,7 +362,12 @@ async def handle_config_info(
),
vol.Optional("schedule"): vol.Schema(
{
vol.Optional("state"): vol.All(str, vol.Coerce(ScheduleState)),
vol.Optional("days"): vol.Any(
vol.All([vol.Coerce(Day)], vol.Unique()),
),
vol.Optional("recurrence"): vol.All(
str, vol.Coerce(ScheduleRecurrence)
),
vol.Optional("time"): vol.Any(cv.time, None),
}
),