mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Add DHCP discovery to LG ThinQ (#145746)
This commit is contained in:
parent
719dd09eb3
commit
ff2fd7e9ef
@ -3,6 +3,7 @@
|
|||||||
"name": "LG ThinQ",
|
"name": "LG ThinQ",
|
||||||
"codeowners": ["@LG-ThinQ-Integration"],
|
"codeowners": ["@LG-ThinQ-Integration"],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
|
"dhcp": [{ "macaddress": "34E6E6*" }],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/lg_thinq",
|
"documentation": "https://www.home-assistant.io/integrations/lg_thinq",
|
||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
"loggers": ["thinqconnect"],
|
"loggers": ["thinqconnect"],
|
||||||
|
4
homeassistant/generated/dhcp.py
generated
4
homeassistant/generated/dhcp.py
generated
@ -444,6 +444,10 @@ DHCP: Final[list[dict[str, str | bool]]] = [
|
|||||||
"domain": "lametric",
|
"domain": "lametric",
|
||||||
"registered_devices": True,
|
"registered_devices": True,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"domain": "lg_thinq",
|
||||||
|
"macaddress": "34E6E6*",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"domain": "lifx",
|
"domain": "lifx",
|
||||||
"macaddress": "D073D5*",
|
"macaddress": "D073D5*",
|
||||||
|
@ -3,15 +3,22 @@
|
|||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
from homeassistant.components.lg_thinq.const import CONF_CONNECT_CLIENT_ID, DOMAIN
|
from homeassistant.components.lg_thinq.const import CONF_CONNECT_CLIENT_ID, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_DHCP, SOURCE_USER
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_COUNTRY
|
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_COUNTRY
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
|
|
||||||
from .const import MOCK_CONNECT_CLIENT_ID, MOCK_COUNTRY, MOCK_PAT
|
from .const import MOCK_CONNECT_CLIENT_ID, MOCK_COUNTRY, MOCK_PAT
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
DHCP_DISCOVERY = DhcpServiceInfo(
|
||||||
|
ip="1.1.1.1",
|
||||||
|
hostname="LG_Smart_Dryer2_open",
|
||||||
|
macaddress="34:E6:E6:11:22:33",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_config_flow(
|
async def test_config_flow(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -70,3 +77,45 @@ async def test_config_flow_already_configured(
|
|||||||
)
|
)
|
||||||
assert result["type"] is FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_dhcp_config_flow(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_config_thinq_api: AsyncMock,
|
||||||
|
mock_uuid: AsyncMock,
|
||||||
|
mock_setup_entry: AsyncMock,
|
||||||
|
) -> None:
|
||||||
|
"""Test that a thinq entry is normally created."""
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN, context={"source": SOURCE_DHCP}, data=DHCP_DISCOVERY
|
||||||
|
)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
result["flow_id"],
|
||||||
|
user_input={CONF_ACCESS_TOKEN: MOCK_PAT, CONF_COUNTRY: MOCK_COUNTRY},
|
||||||
|
)
|
||||||
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
assert result["data"] == {
|
||||||
|
CONF_ACCESS_TOKEN: MOCK_PAT,
|
||||||
|
CONF_COUNTRY: MOCK_COUNTRY,
|
||||||
|
CONF_CONNECT_CLIENT_ID: MOCK_CONNECT_CLIENT_ID,
|
||||||
|
}
|
||||||
|
|
||||||
|
mock_config_thinq_api.async_get_device_list.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
async def test_dhcp_config_flow_already_configured(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
mock_config_thinq_api: AsyncMock,
|
||||||
|
) -> None:
|
||||||
|
"""Test that thinq flow should be aborted when already configured."""
|
||||||
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN, context={"source": SOURCE_DHCP}, data=DHCP_DISCOVERY
|
||||||
|
)
|
||||||
|
assert result["type"] is FlowResultType.ABORT
|
||||||
|
assert result["reason"] == "already_configured"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user