Skip to content

Commit 2183109

Browse files
Add driver firmware v15 commands
1 parent c31be03 commit 2183109

File tree

4 files changed

+62
-27
lines changed

4 files changed

+62
-27
lines changed

test/model/test_controller.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,21 +2172,6 @@ async def test_get_known_lifeline_routes_rssi_error(
21722172
}
21732173

21742174

2175-
async def test_is_firmware_update_in_progress(controller, uuid4, mock_command):
2176-
"""Test is_firmware_update_in_progress command."""
2177-
ack_commands = mock_command(
2178-
{"command": "controller.is_firmware_update_in_progress"},
2179-
{"progress": True},
2180-
)
2181-
assert await controller.async_is_firmware_update_in_progress()
2182-
2183-
assert len(ack_commands) == 1
2184-
assert ack_commands[0] == {
2185-
"command": "controller.is_firmware_update_in_progress",
2186-
"messageId": uuid4,
2187-
}
2188-
2189-
21902175
async def test_nvm_events(controller):
21912176
"""Test NVM progress events."""
21922177
event = Event(

test/model/test_driver.py

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@
77
from zwave_js_server.const import LogLevel
88
from zwave_js_server.event import Event
99
from zwave_js_server.model import (
10-
driver as driver_pkg,
1110
log_config as log_config_pkg,
1211
log_message as log_message_pkg,
1312
)
13+
from zwave_js_server.model.driver import Driver
1414
from zwave_js_server.model.driver.firmware import DriverFirmwareUpdateStatus
1515

1616
from .. import load_fixture
17+
from ..common import MockCommandProtocol
1718

1819

1920
def test_from_state(client, log_config):
2021
"""Test from_state method."""
2122
ws_msgs = load_fixture("basic_dump.txt").strip().split("\n")
2223

23-
driver = driver_pkg.Driver(
24-
client, json.loads(ws_msgs[0])["result"]["state"], log_config
25-
)
26-
assert driver == driver_pkg.Driver(
24+
driver = Driver(client, json.loads(ws_msgs[0])["result"]["state"], log_config)
25+
assert driver == Driver(
2726
client, json.loads(ws_msgs[0])["result"]["state"], log_config
2827
)
2928
assert driver != driver.controller.home_id
@@ -452,3 +451,49 @@ async def test_firmware_events(driver):
452451
assert result.status == DriverFirmwareUpdateStatus.OK
453452
assert result.success
454453
assert driver.firmware_update_progress is None
454+
455+
456+
@pytest.mark.parametrize("progress", [True, False])
457+
async def test_is_otw_firmware_update_in_progress(
458+
driver: Driver,
459+
uuid4: str,
460+
mock_command: MockCommandProtocol,
461+
progress: bool,
462+
) -> None:
463+
"""Test is_otw_firmware_update_in_progress command."""
464+
ack_commands = mock_command(
465+
{"command": "driver.is_otw_firmware_update_in_progress"},
466+
{"progress": progress},
467+
)
468+
assert await driver.async_is_otw_firmware_update_in_progress() is progress
469+
470+
assert len(ack_commands) == 1
471+
assert ack_commands[0] == {
472+
"command": "driver.is_otw_firmware_update_in_progress",
473+
"messageId": uuid4,
474+
}
475+
476+
477+
@pytest.mark.parametrize(("status", "success"), [(1, True), (0, False)])
478+
async def test_firmware_update_otw(
479+
driver: Driver,
480+
uuid4: str,
481+
mock_command: MockCommandProtocol,
482+
status: int,
483+
success: bool,
484+
) -> None:
485+
"""Test firmware_update_otw command."""
486+
ack_commands = mock_command(
487+
{"command": "driver.firmware_update_otw"},
488+
{"result": {"status": status, "success": success}},
489+
)
490+
result = await driver.async_firmware_update_otw()
491+
492+
assert result.status == status
493+
assert result.success is success
494+
495+
assert len(ack_commands) == 1
496+
assert ack_commands[0] == {
497+
"command": "driver.firmware_update_otw",
498+
"messageId": uuid4,
499+
}

zwave_js_server/model/controller/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -876,13 +876,6 @@ async def async_firmware_update_ota(
876876
)
877877
return NodeFirmwareUpdateResult(node, data["result"])
878878

879-
async def async_is_firmware_update_in_progress(self) -> bool:
880-
"""Send isFirmwareUpdateInProgress command to Controller."""
881-
data = await self.client.async_send_command(
882-
{"command": "controller.is_firmware_update_in_progress"}, require_schema=26
883-
)
884-
return cast(bool, data["progress"])
885-
886879
def receive_event(self, event: Event) -> None:
887880
"""Receive an event."""
888881
if event.data["source"] == "node":

zwave_js_server/model/driver/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,18 @@ async def async_install_config_update(self) -> bool:
221221
)
222222
return cast(bool, result["success"])
223223

224+
async def async_firmware_update_otw(self) -> DriverFirmwareUpdateResult:
225+
"""Send firmwareUpdateOTW command to Driver."""
226+
data = await self._async_send_command("firmware_update_otw", require_schema=41)
227+
return DriverFirmwareUpdateResult(data["result"])
228+
229+
async def async_is_otw_firmware_update_in_progress(self) -> bool:
230+
"""Send isOTWFirmwareUpdateInProgress command to Driver."""
231+
result = await self._async_send_command(
232+
"is_otw_firmware_update_in_progress", require_schema=41
233+
)
234+
return cast(bool, result["progress"])
235+
224236
async def async_set_preferred_scales(
225237
self, scales: dict[str | int, str | int]
226238
) -> None:

0 commit comments

Comments
 (0)