UniFi - Simplify getting controller from config entry (#26335)

* Simplify getting controller from config entry

* Lint ignore no longer needed

* Fix tests
This commit is contained in:
Robert Svensson authored and GitHub committed 2019-09-01 17:57:25 +02:00
1 parent 5b77a357e6
commit b5426761f4
7 files changed
+38 -33

No files matched your search

@@ -5,7 +5,7 @@ import logging
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import unifi
from homeassistant.components.unifi.config_flow import get_controller_from_config_entry
from homeassistant.components.device_tracker import DOMAIN, PLATFORM_SCHEMA
from homeassistant.components.device_tracker.config_entry import ScannerEntity
from homeassistant.components.device_tracker.const import SOURCE_TYPE_ROUTER
@@ -29,7 +29,6 @@ from .const import (
ATTR_MANUFACTURER,
CONF_CONTROLLER,
CONF_SITE_ID,
CONTROLLER_ID,
DOMAIN as UNIFI_DOMAIN,
)
@@ -106,11 +105,7 @@ async def async_setup_scanner(hass, config, sync_see, discovery_info):
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up device tracker for UniFi component."""
controller_id = CONTROLLER_ID.format(
host=config_entry.data[CONF_CONTROLLER][CONF_HOST],
site=config_entry.data[CONF_CONTROLLER][CONF_SITE_ID],
)
controller = hass.data[unifi.DOMAIN][controller_id]
controller = get_controller_from_config_entry(hass, config_entry)
tracked = {}
registry = await entity_registry.async_get_registry(hass)