Skip to content

Commit 30be1a6

Browse files
authored
Remove "Nabu Casa" from device name (#539)
* Remove "Nabu Casa" from device name * Add `test_name_nabu_casa_devices` test * Combine coordinator naming tests using `parametrize`
1 parent cd86906 commit 30be1a6

File tree

2 files changed

+44
-30
lines changed

2 files changed

+44
-30
lines changed

tests/test_device.py

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -353,34 +353,44 @@ async def test_device_is_active_coordinator(
353353
assert not stale_coordinator.is_active_coordinator
354354

355355

356-
async def test_coordinator_info_uses_node_info(
357-
zha_gateway: Gateway,
358-
) -> None:
359-
"""Test that the current coordinator uses strings from `node_info`."""
360-
361-
current_coord_dev = zigpy_device(
362-
zha_gateway, ieee="aa:bb:cc:dd:ee:ff:00:11", nwk=0x0000
363-
)
364-
current_coord_dev.node_desc = current_coord_dev.node_desc.replace(
365-
logical_type=zdo_t.LogicalType.Coordinator
366-
)
367-
368-
app = current_coord_dev.application
369-
app.state.node_info.ieee = current_coord_dev.ieee
370-
app.state.node_info.model = "Real Coordinator Model"
371-
app.state.node_info.manufacturer = "Real Coordinator Manufacturer"
372-
373-
current_coordinator = await join_zigpy_device(zha_gateway, current_coord_dev)
374-
assert current_coordinator.is_active_coordinator
375-
376-
assert current_coordinator.model == "Real Coordinator Model"
377-
assert current_coordinator.manufacturer == "Real Coordinator Manufacturer"
378-
379-
380-
async def test_coordinator_info_generic_name(
356+
@pytest.mark.parametrize(
357+
# node_info is populated with manf and model strings
358+
("manf", "model", "expected_manf", "expected_model", "expected_name"),
359+
[
360+
("RealManf", "RealModel", "RealManf", "RealModel", "RealManf RealModel"),
361+
(
362+
"RealManf",
363+
None,
364+
"RealManf",
365+
"Generic Zigbee Coordinator (EZSP)",
366+
"RealManf Generic Zigbee Coordinator (EZSP)",
367+
),
368+
(None, "RealModel", "", "RealModel", " RealModel"),
369+
(
370+
None,
371+
None,
372+
"",
373+
"Generic Zigbee Coordinator (EZSP)",
374+
" Generic Zigbee Coordinator (EZSP)",
375+
),
376+
(
377+
"Nabu Casa",
378+
"Home Assistant Connect ZBT-2",
379+
"Nabu Casa",
380+
"Home Assistant Connect ZBT-2",
381+
"Home Assistant Connect ZBT-2",
382+
),
383+
],
384+
)
385+
async def test_coordinator_info_names(
381386
zha_gateway: Gateway,
387+
manf,
388+
model,
389+
expected_manf,
390+
expected_model,
391+
expected_name,
382392
) -> None:
383-
"""Test that the current coordinator uses strings from `node_info`."""
393+
"""Test that the current coordinator device is named correctly."""
384394

385395
current_coord_dev = zigpy_device(
386396
zha_gateway, ieee="aa:bb:cc:dd:ee:ff:00:11", nwk=0x0000
@@ -391,14 +401,15 @@ async def test_coordinator_info_generic_name(
391401

392402
app = current_coord_dev.application
393403
app.state.node_info.ieee = current_coord_dev.ieee
394-
app.state.node_info.model = None
395-
app.state.node_info.manufacturer = None
404+
app.state.node_info.manufacturer = manf
405+
app.state.node_info.model = model
396406

397407
current_coordinator = await join_zigpy_device(zha_gateway, current_coord_dev)
398408
assert current_coordinator.is_active_coordinator
399409

400-
assert current_coordinator.model == "Generic Zigbee Coordinator (EZSP)"
401-
assert current_coordinator.manufacturer == ""
410+
assert current_coordinator.manufacturer == expected_manf
411+
assert current_coordinator.model == expected_model
412+
assert current_coordinator.name == expected_name
402413

403414

404415
async def test_async_get_clusters(

zha/zigbee/device.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ def device(self) -> zigpy.device.Device:
323323
@cached_property
324324
def name(self) -> str:
325325
"""Return device name."""
326+
# Nabu Casa devices include a brand name in the model
327+
if self.manufacturer == "Nabu Casa":
328+
return self.model
326329
return f"{self.manufacturer} {self.model}"
327330

328331
@property

0 commit comments

Comments
 (0)