diff --git a/homeassistant/components/doorbird/.translations/en.json b/homeassistant/components/doorbird/.translations/en.json index dc7c2fd0cbe..9b2c95dd7c9 100644 --- a/homeassistant/components/doorbird/.translations/en.json +++ b/homeassistant/components/doorbird/.translations/en.json @@ -1,34 +1,36 @@ { - "config": { - "abort": { - "already_configured": "This DoorBird is already configured" - }, - "error": { - "cannot_connect": "Failed to connect, please try again", - "invalid_auth": "Invalid authentication", - "unknown": "Unexpected error" - }, - "step": { - "user": { - "data": { - "host": "Host (IP Address)", - "name": "Device Name", - "password": "Password", - "username": "Username" - }, - "title": "Connect to the DoorBird" + "options" : { + "step" : { + "init" : { + "data" : { + "events" : "Comma separated list of events." + }, + "description" : "Add an comma separated event name for each event you wish to track. After entering them here, use the DoorBird app to assign them to a specific event. See the documentation at https://www.home-assistant.io/integrations/doorbird/#events. Example: somebody_pressed_the_button, motion" + } + } + }, + "config" : { + "step" : { + "user" : { + "title" : "Connect to the DoorBird", + "data" : { + "password" : "Password", + "host" : "Host (IP Address)", + "name" : "Device Name", + "username" : "Username" } - }, - "title": "DoorBird" - }, - "options": { - "step": { - "init": { - "data": { - "events": "Comma separated list of events." - }, - "description": "Add an comma separated event name for each event you wish to track. After entering them here, use the DoorBird app to assign them to a specific event. See the documentation at https://www.home-assistant.io/integrations/doorbird/#events. Example: somebody_pressed_the_button, motion" - } - } - } -} \ No newline at end of file + } + }, + "abort" : { + "already_configured" : "This DoorBird is already configured", + "link_local_address": "Link local addresses are not supported", + "not_doorbird_device": "This device is not a DoorBird" + }, + "title" : "DoorBird", + "error" : { + "invalid_auth" : "Invalid authentication", + "unknown" : "Unexpected error", + "cannot_connect" : "Failed to connect, please try again" + } + } +} diff --git a/homeassistant/components/doorbird/config_flow.py b/homeassistant/components/doorbird/config_flow.py index 37d46c23a9d..410fb13a212 100644 --- a/homeassistant/components/doorbird/config_flow.py +++ b/homeassistant/components/doorbird/config_flow.py @@ -90,6 +90,8 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): if macaddress[:6] != DOORBIRD_OUI: return self.async_abort(reason="not_doorbird_device") + if discovery_info[CONF_HOST].startswith("169.254"): + return self.async_abort(reason="link_local_address") await self.async_set_unique_id(macaddress) diff --git a/homeassistant/components/doorbird/strings.json b/homeassistant/components/doorbird/strings.json index caf3177c681..9b2c95dd7c9 100644 --- a/homeassistant/components/doorbird/strings.json +++ b/homeassistant/components/doorbird/strings.json @@ -22,7 +22,9 @@ } }, "abort" : { - "already_configured" : "This DoorBird is already configured" + "already_configured" : "This DoorBird is already configured", + "link_local_address": "Link local addresses are not supported", + "not_doorbird_device": "This device is not a DoorBird" }, "title" : "DoorBird", "error" : { diff --git a/tests/components/doorbird/test_config_flow.py b/tests/components/doorbird/test_config_flow.py index 009062d0193..f911787c1c3 100644 --- a/tests/components/doorbird/test_config_flow.py +++ b/tests/components/doorbird/test_config_flow.py @@ -140,10 +140,33 @@ async def test_form_zeroconf_wrong_oui(hass): context={"source": config_entries.SOURCE_ZEROCONF}, data={ "properties": {"macaddress": "notdoorbirdoui"}, + "host": "192.168.1.8", "name": "Doorstation - abc123._axis-video._tcp.local.", }, ) assert result["type"] == "abort" + assert result["reason"] == "not_doorbird_device" + + +async def test_form_zeroconf_link_local_ignored(hass): + """Test we abort when we get a link local address via zeroconf.""" + await hass.async_add_executor_job( + init_recorder_component, hass + ) # force in memory db + + await setup.async_setup_component(hass, "persistent_notification", {}) + + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_ZEROCONF}, + data={ + "properties": {"macaddress": "1CCAE3DOORBIRD"}, + "host": "169.254.103.61", + "name": "Doorstation - abc123._axis-video._tcp.local.", + }, + ) + assert result["type"] == "abort" + assert result["reason"] == "link_local_address" async def test_form_zeroconf_correct_oui(hass):