Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retry functionality failing of Unifi #17927

Merged
merged 1 commit into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions homeassistant/components/unifi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions tests/components/unifi/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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):
Expand Down