Skip to content
Merged
2 changes: 1 addition & 1 deletion homeassistant/components/roomba/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async def async_step_dhcp(self, dhcp_discovery):
if self._async_host_already_configured(dhcp_discovery[IP_ADDRESS]):
return self.async_abort(reason="already_configured")

if not dhcp_discovery[HOSTNAME].startswith("iRobot-"):
if not dhcp_discovery[HOSTNAME].startswith(("iRobot-", "Roomba-")):
return self.async_abort(reason="not_irobot_device")

blid = _async_blid_from_hostname(dhcp_discovery[HOSTNAME])
Expand Down
12 changes: 11 additions & 1 deletion homeassistant/components/roomba/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,15 @@
"documentation": "https://www.home-assistant.io/integrations/roomba",
"requirements": ["roombapy==1.6.2"],
"codeowners": ["@pschmitt", "@cyr-ius", "@shenxn"],
"dhcp": [{"hostname":"irobot-*","macaddress":"501479*"}]
"dhcp": [
{
"hostname" : "irobot-*",
"macaddress" : "501479*"
},
{
"hostname" : "roomba-*",
"macaddress" : "80A589*"
}
]
}

5 changes: 5 additions & 0 deletions homeassistant/generated/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@
"hostname": "irobot-*",
"macaddress": "501479*"
},
{
"domain": "roomba",
"hostname": "roomba-*",
"macaddress": "80A589*"
},
{
"domain": "screenlogic",
"hostname": "pentair: *",
Expand Down
48 changes: 35 additions & 13 deletions tests/components/roomba/test_config_flow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test the iRobot Roomba config flow."""
from unittest.mock import MagicMock, PropertyMock, patch

import pytest
from roombapy import RoombaConnectionError
from roombapy.roomba import RoombaInfo

Expand All @@ -12,7 +13,34 @@
from tests.common import MockConfigEntry

MOCK_IP = "1.2.3.4"
VALID_CONFIG = {CONF_HOST: "1.2.3.4", CONF_BLID: "blid", CONF_PASSWORD: "password"}
VALID_CONFIG = {CONF_HOST: MOCK_IP, CONF_BLID: "blid", CONF_PASSWORD: "password"}

DHCP_DISCOVERY_DEVICES = [
{
IP_ADDRESS: MOCK_IP,
MAC_ADDRESS: "50:14:79:DD:EE:FF",
HOSTNAME: "iRobot-blid",
},
{
IP_ADDRESS: MOCK_IP,
MAC_ADDRESS: "80:A5:89:DD:EE:FF",
HOSTNAME: "Roomba-blid",
},
]


DHCP_DISCOVERY_DEVICES_WITHOUT_MATCHING_IP = [
{
IP_ADDRESS: "1.1.1.1",
MAC_ADDRESS: "50:14:79:DD:EE:FF",
HOSTNAME: "iRobot-blid",
},
{
IP_ADDRESS: "1.1.1.1",
MAC_ADDRESS: "80:A5:89:DD:EE:FF",
HOSTNAME: "Roomba-blid",
},
]


def _create_mocked_roomba(
Expand Down Expand Up @@ -577,7 +605,8 @@ async def test_form_user_discovery_and_password_fetch_gets_connection_refused(ha
assert len(mock_setup_entry.mock_calls) == 1


async def test_dhcp_discovery_and_roomba_discovery_finds(hass):
@pytest.mark.parametrize("discovery_data", DHCP_DISCOVERY_DEVICES)
async def test_dhcp_discovery_and_roomba_discovery_finds(hass, discovery_data):
"""Test we can process the discovery from dhcp and roomba discovery matches the device."""
await setup.async_setup_component(hass, "persistent_notification", {})

Expand All @@ -592,11 +621,7 @@ async def test_dhcp_discovery_and_roomba_discovery_finds(hass):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_DHCP},
data={
IP_ADDRESS: MOCK_IP,
MAC_ADDRESS: "AA:BB:CC:DD:EE:FF",
HOSTNAME: "iRobot-blid",
},
data=discovery_data,
)
await hass.async_block_till_done()

Expand Down Expand Up @@ -637,7 +662,8 @@ async def test_dhcp_discovery_and_roomba_discovery_finds(hass):
assert len(mock_setup_entry.mock_calls) == 1


async def test_dhcp_discovery_falls_back_to_manual(hass):
@pytest.mark.parametrize("discovery_data", DHCP_DISCOVERY_DEVICES_WITHOUT_MATCHING_IP)
async def test_dhcp_discovery_falls_back_to_manual(hass, discovery_data):
"""Test we can process the discovery from dhcp but roomba discovery cannot find the device."""
await setup.async_setup_component(hass, "persistent_notification", {})

Expand All @@ -652,11 +678,7 @@ async def test_dhcp_discovery_falls_back_to_manual(hass):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_DHCP},
data={
IP_ADDRESS: "1.1.1.1",
MAC_ADDRESS: "AA:BB:CC:DD:EE:FF",
HOSTNAME: "iRobot-blid",
},
data=discovery_data,
)
await hass.async_block_till_done()

Expand Down