Use ZeroconfServiceInfo in rainmachine (#60055)

This commit is contained in:
epenet 2021-11-21 08:08:45 +01:00 committed by GitHub
parent e056f9aa0f
commit 85b37a8532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -70,7 +70,7 @@ class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle discovery via zeroconf."""
ip_address = discovery_info["host"]
ip_address = discovery_info[zeroconf.ATTR_HOST]
self._async_abort_entries_match({CONF_IP_ADDRESS: ip_address})
# Handle IP change

View File

@ -5,6 +5,7 @@ import pytest
from regenmaschine.errors import RainMachineError
from homeassistant import config_entries, data_entry_flow
from homeassistant.components import zeroconf
from homeassistant.components.rainmachine import CONF_ZONE_RUN_TIME, DOMAIN
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_SSL
@ -171,7 +172,7 @@ async def test_step_homekit_zeroconf_ip_already_exists(hass, source):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": source},
data={"host": "192.168.1.100"},
data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"),
)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
@ -200,7 +201,7 @@ async def test_step_homekit_zeroconf_ip_change(hass, source):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": source},
data={"host": "192.168.1.2"},
data=zeroconf.ZeroconfServiceInfo(host="192.168.1.2"),
)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
@ -231,7 +232,7 @@ async def test_step_homekit_zeroconf_new_controller_when_some_exist(hass, source
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": source},
data={"host": "192.168.1.100"},
data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"),
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -275,7 +276,7 @@ async def test_discovery_by_homekit_and_zeroconf_same_time(hass):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_ZEROCONF},
data={"host": "192.168.1.100"},
data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"),
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -288,7 +289,7 @@ async def test_discovery_by_homekit_and_zeroconf_same_time(hass):
result2 = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_HOMEKIT},
data={"host": "192.168.1.100"},
data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"),
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_ABORT