Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion test/model/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1769,13 +1769,24 @@ async def test_restore_nvm(controller, uuid4, mock_command):
{"command": "controller.restore_nvm"},
{},
)
await controller.async_restore_nvm(bytes(10))
await controller.async_restore_nvm(bytes(10), {})

assert len(ack_commands) == 1
assert ack_commands[0] == {
"command": "controller.restore_nvm",
"nvmData": "AAAAAAAAAAAAAA==",
"messageId": uuid4,
"migrateOptions": {},
}

await controller.async_restore_nvm(bytes(10), {"preserveRoutes": False})

assert len(ack_commands) == 2
assert ack_commands[1] == {
"command": "controller.restore_nvm",
"nvmData": "AAAAAAAAAAAAAA==",
"messageId": uuid4,
"migrateOptions": {"preserveRoutes": False},
}


Expand Down Expand Up @@ -1807,6 +1818,7 @@ async def test_restore_nvm_base64(controller, uuid4, mock_command):
"command": "controller.restore_nvm",
"nvmData": "AAAAAAAAAAAAAA==",
"messageId": uuid4,
"migrateOptions": {},
}


Expand Down
14 changes: 10 additions & 4 deletions zwave_js_server/model/controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,14 +736,17 @@ async def async_backup_nvm_raw(self) -> bytes:
)
return convert_base64_to_bytes(data["nvmData"])

async def async_restore_nvm(self, file: bytes) -> None:
async def async_restore_nvm(
self, file: bytes, options: dict[str, bool] | None = None
) -> None:
"""Send restoreNVM command to Controller."""
await self.client.async_send_command(
{
"command": "controller.restore_nvm",
"nvmData": convert_bytes_to_base64(file),
"migrateOptions": {} if options is None else options,
},
require_schema=14,
require_schema=42,
)

async def async_backup_nvm_raw_base64(self) -> str:
Expand All @@ -753,14 +756,17 @@ async def async_backup_nvm_raw_base64(self) -> str:
)
return data["nvmData"]

async def async_restore_nvm_base64(self, base64_data: str) -> None:
async def async_restore_nvm_base64(
self, base64_data: str, options: dict[str, bool] | None = None
) -> None:
"""Send restoreNVM command to Controller with base64 data directly."""
await self.client.async_send_command(
{
"command": "controller.restore_nvm",
"nvmData": base64_data,
"migrateOptions": {} if options is None else options,
},
require_schema=14,
require_schema=42,
)

async def async_get_power_level(self) -> dict[str, int]:
Expand Down