mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Fix Fully Kiosk IP update from DHCP when another tablet is ignored (#195252)
This commit is contained in:
@@ -131,7 +131,7 @@ class FullyKioskConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle dhcp discovery."""
|
||||
mac = format_mac(discovery_info.macaddress)
|
||||
|
||||
for entry in self._async_current_entries():
|
||||
for entry in self._async_current_entries(include_ignore=False):
|
||||
if entry.data[CONF_MAC] == mac:
|
||||
self.hass.config_entries.async_update_entry(
|
||||
entry,
|
||||
|
||||
@@ -8,7 +8,12 @@ import pytest
|
||||
from pytest_homeassistant.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
from homeassistant.components.fully_kiosk.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_DHCP, SOURCE_MQTT, SOURCE_USER
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_DHCP,
|
||||
SOURCE_IGNORE,
|
||||
SOURCE_MQTT,
|
||||
SOURCE_USER,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_MAC,
|
||||
@@ -164,6 +169,31 @@ async def test_duplicate_updates_existing_entry(
|
||||
assert len(mock_fully_kiosk_config_flow.getDeviceInfo.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery_with_ignored_entry(
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test DHCP discovery updates the entry when another device is ignored."""
|
||||
MockConfigEntry(
|
||||
domain=DOMAIN, unique_id="ignored", source=SOURCE_IGNORE, data={}
|
||||
).add_to_hass(hass)
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_DHCP},
|
||||
data=DhcpServiceInfo(
|
||||
hostname="tablet",
|
||||
ip="127.0.0.2",
|
||||
macaddress="aabbccddeeff",
|
||||
),
|
||||
)
|
||||
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
assert mock_config_entry.data[CONF_HOST] == "127.0.0.2"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_setup_entry")
|
||||
async def test_dhcp_discovery_updates_entry(
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
|
||||
Reference in New Issue
Block a user