-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
Make WS command backup/generate send events #130524
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
@dataclass(slots=True) | ||
class BackupProgress: | ||
"""Backup progress class.""" | ||
|
||
done: bool | ||
stage: str | None | ||
success: bool | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is inspired by backup job progress fired by supervisor:
event_type: supervisor_event
data:
event: job
data:
name: backup_manager_partial_backup
reference: a945ac38
uuid: 6a6ab1807ed64ca18ab1d03fb2fd2282
progress: 0
stage: finishing_file
done: true
parent_id: null
errors: []
@@ -127,7 +132,6 @@ async def handle_backup_start( | |||
) -> None: | |||
"""Backup start notification.""" | |||
manager = hass.data[DATA_MANAGER] | |||
manager.backing_up = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This did not seem to be needed.
with patch( | ||
"homeassistant.components.backup.manager.BackupManager.async_create_backup", | ||
return_value=TEST_BACKUP, | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patching is replaced by mocking the backup file creation to better test the cooperation between the WS handler and the backup manager
) -> None: | ||
"""Test generating a backup.""" | ||
await setup_backup_integration(hass, with_hassio=with_hassio) | ||
|
||
client = await hass_ws_client(hass) | ||
freezer.move_to("2024-11-13 12:01:00+01:00") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time frozen to make the backup slug stable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Some code (the backup service) needs updating.
Proposed change
Make WS command
backup/generate
send eventsRationale:
Creating a backup may need a very long time to finish. To allow frontend to show progress, we let the command immediately return the backup slug, and then fire off events as the backup job progresses
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: