Make device tracker entities work better (#63328)
Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
d4310f0d70
commit
2b4bb49eb7
32 changed files with 546 additions and 357 deletions
|
@ -14,25 +14,33 @@ from homeassistant.components.device_tracker.const import (
|
|||
SOURCE_TYPE_ROUTER,
|
||||
)
|
||||
from homeassistant.const import ATTR_BATTERY_LEVEL, STATE_HOME, STATE_NOT_HOME
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_scanner_entity_device_tracker(hass, enable_custom_integrations):
|
||||
"""Test ScannerEntity based device tracker."""
|
||||
# Make device tied to other integration so device tracker entities get enabled
|
||||
dr.async_get(hass).async_get_or_create(
|
||||
name="Device from other integration",
|
||||
config_entry_id=MockConfigEntry().entry_id,
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, "ad:de:ef:be:ed:fe")},
|
||||
)
|
||||
|
||||
config_entry = MockConfigEntry(domain="test")
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_forward_entry_setup(config_entry, DOMAIN)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_id = "device_tracker.unnamed_device"
|
||||
entity_id = "device_tracker.test_ad_de_ef_be_ed_fe"
|
||||
entity_state = hass.states.get(entity_id)
|
||||
assert entity_state.attributes == {
|
||||
ATTR_SOURCE_TYPE: SOURCE_TYPE_ROUTER,
|
||||
ATTR_BATTERY_LEVEL: 100,
|
||||
ATTR_IP: "0.0.0.0",
|
||||
ATTR_MAC: "ad:de:ef:be:ed:fe:",
|
||||
ATTR_MAC: "ad:de:ef:be:ed:fe",
|
||||
ATTR_HOST_NAME: "test.hostname.org",
|
||||
}
|
||||
assert entity_state.state == STATE_NOT_HOME
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue