Skip to content

Commit fc6844b

Browse files
authored
Add _attr_has_entity_name to devolo Home Network device tracker platform (home-assistant#146978)
* Add _attr_has_entity_name to devolo Home Network device tracker platform * Set name * Fix tests
1 parent 8e82e3a commit fc6844b

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

homeassistant/components/devolo_home_network/device_tracker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class DevoloScannerEntity( # pylint: disable=hass-enforce-class-module
8787
):
8888
"""Representation of a devolo device tracker."""
8989

90+
_attr_has_entity_name = True
9091
_attr_translation_key = "device_tracker"
9192

9293
def __init__(
@@ -99,6 +100,7 @@ def __init__(
99100
super().__init__(coordinator)
100101
self._device = device
101102
self._attr_mac_address = mac
103+
self._attr_name = mac
102104

103105
@property
104106
def extra_state_attributes(self) -> dict[str, str]:

tests/components/devolo_home_network/snapshots/test_device_tracker.ambr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
StateSnapshot({
44
'attributes': ReadOnlyDict({
55
'band': '5 GHz',
6+
'friendly_name': 'AA:BB:CC:DD:EE:FF',
67
'mac': 'AA:BB:CC:DD:EE:FF',
78
'source_type': <SourceType.ROUTER: 'router'>,
89
'wifi': 'Main',
910
}),
1011
'context': <ANY>,
11-
'entity_id': 'device_tracker.devolo_home_network_1234567890_aa_bb_cc_dd_ee_ff',
12+
'entity_id': 'device_tracker.aa_bb_cc_dd_ee_ff',
1213
'last_changed': <ANY>,
1314
'last_reported': <ANY>,
1415
'last_updated': <ANY>,

tests/components/devolo_home_network/test_device_tracker.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
from homeassistant.helpers import entity_registry as er
1818

1919
from . import configure_integration
20-
from .const import CONNECTED_STATIONS, DISCOVERY_INFO, NO_CONNECTED_STATIONS
20+
from .const import CONNECTED_STATIONS, NO_CONNECTED_STATIONS
2121
from .mock import MockDevice
2222

2323
from tests.common import async_fire_time_changed
2424

2525
STATION = CONNECTED_STATIONS[0]
26-
SERIAL = DISCOVERY_INFO.properties["SN"]
2726

2827

2928
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
@@ -35,9 +34,7 @@ async def test_device_tracker(
3534
snapshot: SnapshotAssertion,
3635
) -> None:
3736
"""Test device tracker states."""
38-
state_key = (
39-
f"{PLATFORM}.{DOMAIN}_{SERIAL}_{STATION.mac_address.lower().replace(':', '_')}"
40-
)
37+
state_key = f"{PLATFORM}.{STATION.mac_address.lower().replace(':', '_')}"
4138
entry = configure_integration(hass)
4239
await hass.config_entries.async_setup(entry.entry_id)
4340
await hass.async_block_till_done()
@@ -77,14 +74,12 @@ async def test_restoring_clients(
7774
entity_registry: er.EntityRegistry,
7875
) -> None:
7976
"""Test restoring existing device_tracker entities."""
80-
state_key = (
81-
f"{PLATFORM}.{DOMAIN}_{SERIAL}_{STATION.mac_address.lower().replace(':', '_')}"
82-
)
77+
state_key = f"{PLATFORM}.{STATION.mac_address.lower().replace(':', '_')}"
8378
entry = configure_integration(hass)
8479
entity_registry.async_get_or_create(
8580
PLATFORM,
8681
DOMAIN,
87-
f"{SERIAL}_{STATION.mac_address}",
82+
f"{STATION.mac_address}",
8883
config_entry=entry,
8984
)
9085

0 commit comments

Comments
 (0)