mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 00:27:19 +00:00
Add _attr_has_entity_name to devolo Home Network device tracker platform (#146978)
* Add _attr_has_entity_name to devolo Home Network device tracker platform * Set name * Fix tests
This commit is contained in:
parent
8e82e3aa3a
commit
fc6844b3c9
@ -87,6 +87,7 @@ class DevoloScannerEntity( # pylint: disable=hass-enforce-class-module
|
|||||||
):
|
):
|
||||||
"""Representation of a devolo device tracker."""
|
"""Representation of a devolo device tracker."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
_attr_translation_key = "device_tracker"
|
_attr_translation_key = "device_tracker"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -99,6 +100,7 @@ class DevoloScannerEntity( # pylint: disable=hass-enforce-class-module
|
|||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._device = device
|
self._device = device
|
||||||
self._attr_mac_address = mac
|
self._attr_mac_address = mac
|
||||||
|
self._attr_name = mac
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, str]:
|
def extra_state_attributes(self) -> dict[str, str]:
|
||||||
|
@ -3,12 +3,13 @@
|
|||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'band': '5 GHz',
|
'band': '5 GHz',
|
||||||
|
'friendly_name': 'AA:BB:CC:DD:EE:FF',
|
||||||
'mac': 'AA:BB:CC:DD:EE:FF',
|
'mac': 'AA:BB:CC:DD:EE:FF',
|
||||||
'source_type': <SourceType.ROUTER: 'router'>,
|
'source_type': <SourceType.ROUTER: 'router'>,
|
||||||
'wifi': 'Main',
|
'wifi': 'Main',
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'device_tracker.devolo_home_network_1234567890_aa_bb_cc_dd_ee_ff',
|
'entity_id': 'device_tracker.aa_bb_cc_dd_ee_ff',
|
||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
|
@ -17,13 +17,12 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
|
||||||
from . import configure_integration
|
from . import configure_integration
|
||||||
from .const import CONNECTED_STATIONS, DISCOVERY_INFO, NO_CONNECTED_STATIONS
|
from .const import CONNECTED_STATIONS, NO_CONNECTED_STATIONS
|
||||||
from .mock import MockDevice
|
from .mock import MockDevice
|
||||||
|
|
||||||
from tests.common import async_fire_time_changed
|
from tests.common import async_fire_time_changed
|
||||||
|
|
||||||
STATION = CONNECTED_STATIONS[0]
|
STATION = CONNECTED_STATIONS[0]
|
||||||
SERIAL = DISCOVERY_INFO.properties["SN"]
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||||
@ -35,9 +34,7 @@ async def test_device_tracker(
|
|||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test device tracker states."""
|
"""Test device tracker states."""
|
||||||
state_key = (
|
state_key = f"{PLATFORM}.{STATION.mac_address.lower().replace(':', '_')}"
|
||||||
f"{PLATFORM}.{DOMAIN}_{SERIAL}_{STATION.mac_address.lower().replace(':', '_')}"
|
|
||||||
)
|
|
||||||
entry = configure_integration(hass)
|
entry = configure_integration(hass)
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -77,14 +74,12 @@ async def test_restoring_clients(
|
|||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test restoring existing device_tracker entities."""
|
"""Test restoring existing device_tracker entities."""
|
||||||
state_key = (
|
state_key = f"{PLATFORM}.{STATION.mac_address.lower().replace(':', '_')}"
|
||||||
f"{PLATFORM}.{DOMAIN}_{SERIAL}_{STATION.mac_address.lower().replace(':', '_')}"
|
|
||||||
)
|
|
||||||
entry = configure_integration(hass)
|
entry = configure_integration(hass)
|
||||||
entity_registry.async_get_or_create(
|
entity_registry.async_get_or_create(
|
||||||
PLATFORM,
|
PLATFORM,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
f"{SERIAL}_{STATION.mac_address}",
|
f"{STATION.mac_address}",
|
||||||
config_entry=entry,
|
config_entry=entry,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user