Skip to content

Commit b2e431f

Browse files
authored
Add migrateOptions to nvm restore methods (#1245)
* Add `migrateOptions` to nvm restore methods * bump require_schema to 42 * update tests
1 parent 4a12653 commit b2e431f

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

test/model/test_controller.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1769,13 +1769,24 @@ async def test_restore_nvm(controller, uuid4, mock_command):
17691769
{"command": "controller.restore_nvm"},
17701770
{},
17711771
)
1772-
await controller.async_restore_nvm(bytes(10))
1772+
await controller.async_restore_nvm(bytes(10), {})
17731773

17741774
assert len(ack_commands) == 1
17751775
assert ack_commands[0] == {
17761776
"command": "controller.restore_nvm",
17771777
"nvmData": "AAAAAAAAAAAAAA==",
17781778
"messageId": uuid4,
1779+
"migrateOptions": {},
1780+
}
1781+
1782+
await controller.async_restore_nvm(bytes(10), {"preserveRoutes": False})
1783+
1784+
assert len(ack_commands) == 2
1785+
assert ack_commands[1] == {
1786+
"command": "controller.restore_nvm",
1787+
"nvmData": "AAAAAAAAAAAAAA==",
1788+
"messageId": uuid4,
1789+
"migrateOptions": {"preserveRoutes": False},
17791790
}
17801791

17811792

@@ -1807,6 +1818,7 @@ async def test_restore_nvm_base64(controller, uuid4, mock_command):
18071818
"command": "controller.restore_nvm",
18081819
"nvmData": "AAAAAAAAAAAAAA==",
18091820
"messageId": uuid4,
1821+
"migrateOptions": {},
18101822
}
18111823

18121824

zwave_js_server/model/controller/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,14 +736,17 @@ async def async_backup_nvm_raw(self) -> bytes:
736736
)
737737
return convert_base64_to_bytes(data["nvmData"])
738738

739-
async def async_restore_nvm(self, file: bytes) -> None:
739+
async def async_restore_nvm(
740+
self, file: bytes, options: dict[str, bool] | None = None
741+
) -> None:
740742
"""Send restoreNVM command to Controller."""
741743
await self.client.async_send_command(
742744
{
743745
"command": "controller.restore_nvm",
744746
"nvmData": convert_bytes_to_base64(file),
747+
"migrateOptions": {} if options is None else options,
745748
},
746-
require_schema=14,
749+
require_schema=42,
747750
)
748751

749752
async def async_backup_nvm_raw_base64(self) -> str:
@@ -753,14 +756,17 @@ async def async_backup_nvm_raw_base64(self) -> str:
753756
)
754757
return data["nvmData"]
755758

756-
async def async_restore_nvm_base64(self, base64_data: str) -> None:
759+
async def async_restore_nvm_base64(
760+
self, base64_data: str, options: dict[str, bool] | None = None
761+
) -> None:
757762
"""Send restoreNVM command to Controller with base64 data directly."""
758763
await self.client.async_send_command(
759764
{
760765
"command": "controller.restore_nvm",
761766
"nvmData": base64_data,
767+
"migrateOptions": {} if options is None else options,
762768
},
763-
require_schema=14,
769+
require_schema=42,
764770
)
765771

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

0 commit comments

Comments
 (0)