Skip to content

Commit 9dbfc37

Browse files
authored
add node.ping command (#220)
1 parent cc86ba3 commit 9dbfc37

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

test/model/test_node.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,23 @@ async def test_poll_value(multisensor_6, uuid4, mock_command):
203203
}
204204

205205

206+
async def test_ping(multisensor_6, uuid4, mock_command):
207+
"""Test ping."""
208+
node = multisensor_6
209+
ack_commands = mock_command(
210+
{"command": "node.ping", "nodeId": node.node_id},
211+
{"responded": True},
212+
)
213+
assert await node.async_ping()
214+
215+
assert len(ack_commands) == 1
216+
assert ack_commands[0] == {
217+
"command": "node.ping",
218+
"nodeId": node.node_id,
219+
"messageId": uuid4,
220+
}
221+
222+
206223
async def test_refresh_info(multisensor_6, uuid4, mock_command):
207224
"""Test refresh info."""
208225
node = multisensor_6

zwave_js_server/model/node.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,16 @@ async def async_poll_value(self, val: Union[Value, str]) -> None:
445445
val = self.values[val]
446446
await self.async_send_command("poll_value", valueId=val.data, require_schema=1)
447447

448+
async def async_ping(self) -> bool:
449+
"""Send ping command to Node."""
450+
data = (
451+
await self.async_send_command(
452+
"ping", require_schema=5, wait_for_result=True
453+
)
454+
or {}
455+
)
456+
return cast(bool, data.get("responded", False))
457+
448458
def handle_wake_up(self, event: Event) -> None:
449459
"""Process a node wake up event."""
450460
# pylint: disable=unused-argument

0 commit comments

Comments
 (0)