Retry tplink setup later if device has an unexpected mac address (#98784)
Retry tplink setup later if device has an unexpected serial If the DHCP reservation changed and there is now a different tplink device at the saved IP address, retry setup later to avoid cross linking devices
This commit is contained in:
parent
d21ee30ddf
commit
d17ffff3e3
2 changed files with 35 additions and 1 deletions
|
@ -4,6 +4,8 @@ from __future__ import annotations
|
|||
from datetime import timedelta
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant import setup
|
||||
from homeassistant.components import tplink
|
||||
from homeassistant.components.tplink.const import DOMAIN
|
||||
|
@ -111,3 +113,23 @@ async def test_dimmer_switch_unique_id_fix_original_entity_still_exists(
|
|||
)
|
||||
assert migrated_dimmer_entity_reg.entity_id == original_dimmer_entity_reg.entity_id
|
||||
assert migrated_dimmer_entity_reg.entity_id != rollout_dimmer_entity_reg.entity_id
|
||||
|
||||
|
||||
async def test_config_entry_wrong_mac_Address(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test config entry enters setup retry when mac address mismatches."""
|
||||
mismatched_mac = f"{MAC_ADDRESS[:-1]}0"
|
||||
already_migrated_config_entry = MockConfigEntry(
|
||||
domain=DOMAIN, data={CONF_HOST: "127.0.0.1"}, unique_id=mismatched_mac
|
||||
)
|
||||
already_migrated_config_entry.add_to_hass(hass)
|
||||
with _patch_discovery(), _patch_single_discovery():
|
||||
await async_setup_component(hass, tplink.DOMAIN, {tplink.DOMAIN: {}})
|
||||
await hass.async_block_till_done()
|
||||
assert already_migrated_config_entry.state == ConfigEntryState.SETUP_RETRY
|
||||
|
||||
assert (
|
||||
"Unexpected device found at 127.0.0.1; expected aa:bb:cc:dd:ee:f0, found aa:bb:cc:dd:ee:ff"
|
||||
in caplog.text
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue