Add support for Roomba 980 discovery (#47696)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
8896ae0d56
commit
a9ccba44ed
4 changed files with 52 additions and 15 deletions
|
@ -80,7 +80,7 @@ class RoombaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
if self._async_host_already_configured(dhcp_discovery[IP_ADDRESS]):
|
if self._async_host_already_configured(dhcp_discovery[IP_ADDRESS]):
|
||||||
return self.async_abort(reason="already_configured")
|
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")
|
return self.async_abort(reason="not_irobot_device")
|
||||||
|
|
||||||
blid = _async_blid_from_hostname(dhcp_discovery[HOSTNAME])
|
blid = _async_blid_from_hostname(dhcp_discovery[HOSTNAME])
|
||||||
|
|
|
@ -5,5 +5,15 @@
|
||||||
"documentation": "https://www.home-assistant.io/integrations/roomba",
|
"documentation": "https://www.home-assistant.io/integrations/roomba",
|
||||||
"requirements": ["roombapy==1.6.2"],
|
"requirements": ["roombapy==1.6.2"],
|
||||||
"codeowners": ["@pschmitt", "@cyr-ius", "@shenxn"],
|
"codeowners": ["@pschmitt", "@cyr-ius", "@shenxn"],
|
||||||
"dhcp": [{"hostname":"irobot-*","macaddress":"501479*"}]
|
"dhcp": [
|
||||||
|
{
|
||||||
|
"hostname" : "irobot-*",
|
||||||
|
"macaddress" : "501479*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hostname" : "roomba-*",
|
||||||
|
"macaddress" : "80A589*"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,11 @@ DHCP = [
|
||||||
"hostname": "irobot-*",
|
"hostname": "irobot-*",
|
||||||
"macaddress": "501479*"
|
"macaddress": "501479*"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"domain": "roomba",
|
||||||
|
"hostname": "roomba-*",
|
||||||
|
"macaddress": "80A589*"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"domain": "screenlogic",
|
"domain": "screenlogic",
|
||||||
"hostname": "pentair: *",
|
"hostname": "pentair: *",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Test the iRobot Roomba config flow."""
|
"""Test the iRobot Roomba config flow."""
|
||||||
from unittest.mock import MagicMock, PropertyMock, patch
|
from unittest.mock import MagicMock, PropertyMock, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
from roombapy import RoombaConnectionError
|
from roombapy import RoombaConnectionError
|
||||||
from roombapy.roomba import RoombaInfo
|
from roombapy.roomba import RoombaInfo
|
||||||
|
|
||||||
|
@ -12,7 +13,34 @@ from homeassistant.const import CONF_DELAY, CONF_HOST, CONF_PASSWORD
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
MOCK_IP = "1.2.3.4"
|
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(
|
def _create_mocked_roomba(
|
||||||
|
@ -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
|
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."""
|
"""Test we can process the discovery from dhcp and roomba discovery matches the device."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
|
@ -592,11 +621,7 @@ async def test_dhcp_discovery_and_roomba_discovery_finds(hass):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_DHCP},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data=discovery_data,
|
||||||
IP_ADDRESS: MOCK_IP,
|
|
||||||
MAC_ADDRESS: "AA:BB:CC:DD:EE:FF",
|
|
||||||
HOSTNAME: "iRobot-blid",
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
@ -637,7 +662,8 @@ async def test_dhcp_discovery_and_roomba_discovery_finds(hass):
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
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."""
|
"""Test we can process the discovery from dhcp but roomba discovery cannot find the device."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
|
@ -652,11 +678,7 @@ async def test_dhcp_discovery_falls_back_to_manual(hass):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_DHCP},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data=discovery_data,
|
||||||
IP_ADDRESS: "1.1.1.1",
|
|
||||||
MAC_ADDRESS: "AA:BB:CC:DD:EE:FF",
|
|
||||||
HOSTNAME: "iRobot-blid",
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue