diff --git a/homeassistant/components/amazon_devices/manifest.json b/homeassistant/components/amazon_devices/manifest.json index 675433387bb..3f8dcd4c4df 100644 --- a/homeassistant/components/amazon_devices/manifest.json +++ b/homeassistant/components/amazon_devices/manifest.json @@ -3,6 +3,17 @@ "name": "Amazon Devices", "codeowners": ["@chemelli74"], "config_flow": true, + "dhcp": [ + { "macaddress": "10BF67*" }, + { "macaddress": "48B423*" }, + { "macaddress": "4C1744*" }, + { "macaddress": "50DCE7*" }, + { "macaddress": "74D637*" }, + { "macaddress": "9CC8E9*" }, + { "macaddress": "C095CF*" }, + { "macaddress": "D8BE65*" }, + { "macaddress": "EC2BEB*" } + ], "documentation": "https://www.home-assistant.io/integrations/amazon_devices", "integration_type": "hub", "iot_class": "cloud_polling", diff --git a/homeassistant/components/amazon_devices/quality_scale.yaml b/homeassistant/components/amazon_devices/quality_scale.yaml index 1234fd574a3..23a7cd22a66 100644 --- a/homeassistant/components/amazon_devices/quality_scale.yaml +++ b/homeassistant/components/amazon_devices/quality_scale.yaml @@ -42,8 +42,10 @@ rules: # Gold devices: done diagnostics: todo - discovery-update-info: todo - discovery: todo + discovery-update-info: + status: exempt + comment: Network information not relevant + discovery: done docs-data-update: todo docs-examples: todo docs-known-limitations: todo diff --git a/homeassistant/generated/dhcp.py b/homeassistant/generated/dhcp.py index 20b49919ace..cbdf31387e6 100644 --- a/homeassistant/generated/dhcp.py +++ b/homeassistant/generated/dhcp.py @@ -26,6 +26,42 @@ DHCP: Final[list[dict[str, str | bool]]] = [ "domain": "airzone", "macaddress": "E84F25*", }, + { + "domain": "amazon_devices", + "macaddress": "10BF67*", + }, + { + "domain": "amazon_devices", + "macaddress": "48B423*", + }, + { + "domain": "amazon_devices", + "macaddress": "4C1744*", + }, + { + "domain": "amazon_devices", + "macaddress": "50DCE7*", + }, + { + "domain": "amazon_devices", + "macaddress": "74D637*", + }, + { + "domain": "amazon_devices", + "macaddress": "9CC8E9*", + }, + { + "domain": "amazon_devices", + "macaddress": "C095CF*", + }, + { + "domain": "amazon_devices", + "macaddress": "D8BE65*", + }, + { + "domain": "amazon_devices", + "macaddress": "EC2BEB*", + }, { "domain": "august", "hostname": "connect", diff --git a/tests/components/amazon_devices/test_config_flow.py b/tests/components/amazon_devices/test_config_flow.py index e60ae9543a3..68ab7f4ffa6 100644 --- a/tests/components/amazon_devices/test_config_flow.py +++ b/tests/components/amazon_devices/test_config_flow.py @@ -6,15 +6,22 @@ from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect import pytest from homeassistant.components.amazon_devices.const import CONF_LOGIN_DATA, DOMAIN -from homeassistant.config_entries import SOURCE_USER +from homeassistant.config_entries import SOURCE_DHCP, SOURCE_USER from homeassistant.const import CONF_CODE, CONF_COUNTRY, CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType +from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo from .const import TEST_CODE, TEST_COUNTRY, TEST_PASSWORD, TEST_USERNAME from tests.common import MockConfigEntry +DHCP_DISCOVERY = DhcpServiceInfo( + ip="1.1.1.1", + hostname="", + macaddress="c095cfebf19f", +) + async def test_full_flow( hass: HomeAssistant, @@ -132,3 +139,58 @@ async def test_already_configured( assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" + + +async def test_dhcp_flow( + hass: HomeAssistant, + mock_amazon_devices_client: AsyncMock, + mock_setup_entry: AsyncMock, +) -> None: + """Test full DHCP flow.""" + 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"], + { + CONF_COUNTRY: TEST_COUNTRY, + CONF_USERNAME: TEST_USERNAME, + CONF_PASSWORD: TEST_PASSWORD, + CONF_CODE: TEST_CODE, + }, + ) + assert result["type"] is FlowResultType.CREATE_ENTRY + assert result["title"] == TEST_USERNAME + assert result["data"] == { + CONF_COUNTRY: TEST_COUNTRY, + CONF_USERNAME: TEST_USERNAME, + CONF_PASSWORD: TEST_PASSWORD, + CONF_LOGIN_DATA: { + "customer_info": {"user_id": TEST_USERNAME}, + }, + } + assert result["result"].unique_id == TEST_USERNAME + + +async def test_dhcp_already_configured( + hass: HomeAssistant, + mock_amazon_devices_client: AsyncMock, + mock_setup_entry: AsyncMock, + mock_config_entry: MockConfigEntry, +) -> None: + """Test duplicate flow.""" + 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"