Skip to content

Commit cc86ba3

Browse files
authored
Add schema 5 support (#217)
* Add schema 5 suppoort * fix mypy and pylint * add missing test
1 parent 4b66ef9 commit cc86ba3

File tree

5 files changed

+41
-5
lines changed

5 files changed

+41
-5
lines changed

test/fixtures/cover_qubino_shutter_state.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"firmwareVersion": { "min": "0.0", "max": "255.255" },
3636
"paramInformation": { "_map": {} }
3737
},
38+
"deviceDatabaseUrl": "https://devices.zwave-js.io/?jumpTo=0x0159:0x0003:0x0053:0.0",
3839
"label": "ZMNHOD",
3940
"neighbors": [1, 2],
4041
"interviewAttempts": 1,

test/model/test_controller.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,3 +467,21 @@ async def test_remove_node_from_all_associations(controller, uuid4, mock_command
467467
"messageId": uuid4,
468468
"nodeId": node_id,
469469
}
470+
471+
472+
async def test_get_node_neighbors(controller, uuid4, mock_command):
473+
"""Test get node neighbors."""
474+
475+
ack_commands = mock_command(
476+
{"command": "controller.get_node_neighbors"}, {"neighbors": [1, 2]}
477+
)
478+
479+
node_id = 52
480+
assert await controller.async_get_node_neighbors(node_id) == [1, 2]
481+
482+
assert len(ack_commands) == 1
483+
assert ack_commands[0] == {
484+
"command": "controller.get_node_neighbors",
485+
"messageId": uuid4,
486+
"nodeId": node_id,
487+
}

test/model/test_node.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def test_from_state():
5050
assert node.product_id == 90
5151
assert node.product_type == 257
5252
assert node.label == "ZW090"
53-
assert node.neighbors == [23, 26, 5, 6]
5453
assert node.interview_attempts == 0
5554
assert node.installer_icon is None
5655
assert node.user_icon is None
@@ -131,6 +130,14 @@ async def test_unknown_values(cover_qubino_shutter):
131130
)
132131

133132

133+
async def test_device_database_url(cover_qubino_shutter):
134+
"""Test that the device database URL is available."""
135+
assert (
136+
cover_qubino_shutter.device_database_url
137+
== "https://devices.zwave-js.io/?jumpTo=0x0159:0x0003:0x0053:0.0"
138+
)
139+
140+
134141
async def test_values_without_property_key_name(multisensor_6):
135142
"""Test that values with property key and without property key name can be found."""
136143
node = multisensor_6

zwave_js_server/model/controller.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,16 @@ async def async_remove_node_from_all_associations(self, node_id: int) -> None:
324324
}
325325
)
326326

327+
async def async_get_node_neighbors(self, node_id: int) -> List[int]:
328+
"""Send getNodeNeighbors command to Controller to get node's neighbors."""
329+
data = await self.client.async_send_command(
330+
{
331+
"command": "controller.get_node_neighbors",
332+
"nodeId": node_id,
333+
}
334+
)
335+
return cast(List[int], data["neighbors"])
336+
327337
def receive_event(self, event: Event) -> None:
328338
"""Receive an event."""
329339
if event.data["source"] == "node":

zwave_js_server/model/node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class NodeDataType(TypedDict, total=False):
7474
productId: int
7575
productType: int
7676
deviceConfig: DeviceConfigDataType
77-
neighbors: List[int]
77+
deviceDatabaseUrl: str
7878
keepAwake: bool
7979
index: int
8080
installerIcon: int
@@ -262,9 +262,9 @@ def label(self) -> Optional[str]:
262262
return self.data.get("label")
263263

264264
@property
265-
def neighbors(self) -> List[int]:
266-
"""Return the neighbors."""
267-
return self.data.get("neighbors", [])
265+
def device_database_url(self) -> Optional[str]:
266+
"""Return the device database URL."""
267+
return self.data.get("deviceDatabaseUrl")
268268

269269
@property
270270
def endpoints(self) -> List[Endpoint]:

0 commit comments

Comments
 (0)