Do not reload the isy994 on ip change since there is already a reload listener (#54602)

This commit is contained in:
J. Nick Koston 2021-09-17 21:22:14 -10:00 committed by GitHub
parent 539ef31046
commit 0830100df1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 65 deletions

View File

@ -41,7 +41,6 @@ from .const import (
MANUFACTURER,
PLATFORMS,
PROGRAM_PLATFORMS,
UNDO_UPDATE_LISTENER,
)
from .helpers import _categorize_nodes, _categorize_programs, _categorize_variables
from .services import async_setup_services, async_unload_services
@ -218,9 +217,7 @@ async def async_setup_entry(
await hass.async_add_executor_job(_start_auto_update)
undo_listener = entry.add_update_listener(_async_update_listener)
hass_isy_data[UNDO_UPDATE_LISTENER] = undo_listener
entry.async_on_unload(entry.add_update_listener(_async_update_listener))
entry.async_on_unload(
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _stop_auto_update)
)
@ -290,8 +287,6 @@ async def async_unload_entry(
await hass.async_add_executor_job(_stop_auto_update)
hass_isy_data[UNDO_UPDATE_LISTENER]()
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)

View File

@ -182,9 +182,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
),
},
)
self.hass.async_create_task(
self.hass.config_entries.async_reload(existing_entry.entry_id)
)
raise data_entry_flow.AbortFlow("already_configured")
async def async_step_dhcp(self, discovery_info):

View File

@ -183,8 +183,6 @@ TYPE_CATEGORY_X10 = "113."
TYPE_EZIO2X4 = "7.3.255."
TYPE_INSTEON_MOTION = ("16.1.", "16.22.")
UNDO_UPDATE_LISTENER = "undo_update_listener"
# Used for discovery
UDN_UUID_PREFIX = "uuid:"
ISY_URL_POSTFIX = "/desc"

View File

@ -383,12 +383,7 @@ async def test_form_ssdp_existing_entry(hass: HomeAssistant):
)
entry.add_to_hass(hass)
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE), patch(
PATCH_ASYNC_SETUP, return_value=True
) as mock_setup, patch(
PATCH_ASYNC_SETUP_ENTRY,
return_value=True,
) as mock_setup_entry:
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_SSDP},
@ -404,9 +399,6 @@ async def test_form_ssdp_existing_entry(hass: HomeAssistant):
assert result["reason"] == "already_configured"
assert entry.data[CONF_HOST] == f"http://3.3.3.3:80{ISY_URL_POSTFIX}"
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_ssdp_existing_entry_with_no_port(hass: HomeAssistant):
"""Test we update the ip of an existing entry from ssdp with no port."""
@ -418,12 +410,7 @@ async def test_form_ssdp_existing_entry_with_no_port(hass: HomeAssistant):
)
entry.add_to_hass(hass)
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE), patch(
PATCH_ASYNC_SETUP, return_value=True
) as mock_setup, patch(
PATCH_ASYNC_SETUP_ENTRY,
return_value=True,
) as mock_setup_entry:
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_SSDP},
@ -439,9 +426,6 @@ async def test_form_ssdp_existing_entry_with_no_port(hass: HomeAssistant):
assert result["reason"] == "already_configured"
assert entry.data[CONF_HOST] == f"http://3.3.3.3:80/{ISY_URL_POSTFIX}"
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_ssdp_existing_entry_with_alternate_port(hass: HomeAssistant):
"""Test we update the ip of an existing entry from ssdp with an alternate port."""
@ -453,12 +437,7 @@ async def test_form_ssdp_existing_entry_with_alternate_port(hass: HomeAssistant)
)
entry.add_to_hass(hass)
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE), patch(
PATCH_ASYNC_SETUP, return_value=True
) as mock_setup, patch(
PATCH_ASYNC_SETUP_ENTRY,
return_value=True,
) as mock_setup_entry:
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_SSDP},
@ -474,9 +453,6 @@ async def test_form_ssdp_existing_entry_with_alternate_port(hass: HomeAssistant)
assert result["reason"] == "already_configured"
assert entry.data[CONF_HOST] == f"http://3.3.3.3:1443/{ISY_URL_POSTFIX}"
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_ssdp_existing_entry_no_port_https(hass: HomeAssistant):
"""Test we update the ip of an existing entry from ssdp with no port and https."""
@ -488,12 +464,7 @@ async def test_form_ssdp_existing_entry_no_port_https(hass: HomeAssistant):
)
entry.add_to_hass(hass)
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE), patch(
PATCH_ASYNC_SETUP, return_value=True
) as mock_setup, patch(
PATCH_ASYNC_SETUP_ENTRY,
return_value=True,
) as mock_setup_entry:
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_SSDP},
@ -509,9 +480,6 @@ async def test_form_ssdp_existing_entry_no_port_https(hass: HomeAssistant):
assert result["reason"] == "already_configured"
assert entry.data[CONF_HOST] == f"https://3.3.3.3:443/{ISY_URL_POSTFIX}"
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_dhcp(hass: HomeAssistant):
"""Test we can setup from dhcp."""
@ -560,12 +528,7 @@ async def test_form_dhcp_existing_entry(hass: HomeAssistant):
)
entry.add_to_hass(hass)
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE), patch(
PATCH_ASYNC_SETUP, return_value=True
) as mock_setup, patch(
PATCH_ASYNC_SETUP_ENTRY,
return_value=True,
) as mock_setup_entry:
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_DHCP},
@ -581,9 +544,6 @@ async def test_form_dhcp_existing_entry(hass: HomeAssistant):
assert result["reason"] == "already_configured"
assert entry.data[CONF_HOST] == f"http://1.2.3.4{ISY_URL_POSTFIX}"
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_dhcp_existing_entry_preserves_port(hass: HomeAssistant):
"""Test we update the ip of an existing entry from dhcp preserves port."""
@ -598,12 +558,7 @@ async def test_form_dhcp_existing_entry_preserves_port(hass: HomeAssistant):
)
entry.add_to_hass(hass)
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE), patch(
PATCH_ASYNC_SETUP, return_value=True
) as mock_setup, patch(
PATCH_ASYNC_SETUP_ENTRY,
return_value=True,
) as mock_setup_entry:
with patch(PATCH_CONNECTION, return_value=MOCK_CONFIG_RESPONSE):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_DHCP},
@ -619,6 +574,3 @@ async def test_form_dhcp_existing_entry_preserves_port(hass: HomeAssistant):
assert result["reason"] == "already_configured"
assert entry.data[CONF_HOST] == f"http://1.2.3.4:1443{ISY_URL_POSTFIX}"
assert entry.data[CONF_USERNAME] == "bob"
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1