mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix controller not being stored when setup fails and sequentially fails the retry functionality (#17927)
This commit is contained in:
parent
29c9081ca1
commit
04e0fd1d46
@ -32,20 +32,21 @@ async def async_setup(hass, config):
|
||||
|
||||
async def async_setup_entry(hass, config_entry):
|
||||
"""Set up the UniFi component."""
|
||||
controller = UniFiController(hass, config_entry)
|
||||
|
||||
if DOMAIN not in hass.data:
|
||||
hass.data[DOMAIN] = {}
|
||||
|
||||
controller = UniFiController(hass, config_entry)
|
||||
|
||||
controller_id = CONTROLLER_ID.format(
|
||||
host=config_entry.data[CONF_CONTROLLER][CONF_HOST],
|
||||
site=config_entry.data[CONF_CONTROLLER][CONF_SITE_ID]
|
||||
)
|
||||
|
||||
hass.data[DOMAIN][controller_id] = controller
|
||||
|
||||
if not await controller.async_setup():
|
||||
return False
|
||||
|
||||
hass.data[DOMAIN][controller_id] = controller
|
||||
|
||||
if controller.mac is None:
|
||||
return True
|
||||
|
||||
|
@ -54,7 +54,7 @@ async def test_successful_config_entry(hass):
|
||||
|
||||
|
||||
async def test_controller_fail_setup(hass):
|
||||
"""Test that configured options for a host are loaded via config entry."""
|
||||
"""Test that a failed setup still stores controller."""
|
||||
entry = MockConfigEntry(domain=unifi.DOMAIN, data={
|
||||
'controller': {
|
||||
'host': '0.0.0.0',
|
||||
@ -75,7 +75,7 @@ async def test_controller_fail_setup(hass):
|
||||
controller_id = unifi.CONTROLLER_ID.format(
|
||||
host='0.0.0.0', site='default'
|
||||
)
|
||||
assert controller_id not in hass.data[unifi.DOMAIN]
|
||||
assert controller_id in hass.data[unifi.DOMAIN]
|
||||
|
||||
|
||||
async def test_controller_no_mac(hass):
|
||||
|
Loading…
x
Reference in New Issue
Block a user