diff --git a/homeassistant/components/homekit_controller/__init__.py b/homeassistant/components/homekit_controller/__init__.py index 6b53301e877..c863da14a3a 100644 --- a/homeassistant/components/homekit_controller/__init__.py +++ b/homeassistant/components/homekit_controller/__init__.py @@ -5,15 +5,14 @@ import homekit from homekit.model.characteristics import CharacteristicsTypes from homeassistant.core import callback -from homeassistant.helpers.entity import Entity from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import device_registry as dr +from homeassistant.helpers.entity import Entity # We need an import from .config_flow, without it .config_flow is never loaded. from .config_flow import HomekitControllerFlowHandler # noqa: F401 -from .connection import get_accessory_information, HKDevice -from .const import CONTROLLER, ENTITY_MAP, KNOWN_DEVICES -from .const import DOMAIN +from .connection import HKDevice, get_accessory_information +from .const import CONTROLLER, DOMAIN, ENTITY_MAP, KNOWN_DEVICES from .storage import EntityMapStorage _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/homekit_controller/climate.py b/homeassistant/components/homekit_controller/climate.py index 1f9118ff838..d0ab7bd2e99 100644 --- a/homeassistant/components/homekit_controller/climate.py +++ b/homeassistant/components/homekit_controller/climate.py @@ -4,20 +4,20 @@ import logging from homekit.model.characteristics import CharacteristicsTypes from homeassistant.components.climate import ( - ClimateDevice, - DEFAULT_MIN_HUMIDITY, DEFAULT_MAX_HUMIDITY, + DEFAULT_MIN_HUMIDITY, + ClimateDevice, ) from homeassistant.components.climate.const import ( - HVAC_MODE_HEAT_COOL, + CURRENT_HVAC_COOL, + CURRENT_HVAC_HEAT, + CURRENT_HVAC_IDLE, HVAC_MODE_COOL, HVAC_MODE_HEAT, + HVAC_MODE_HEAT_COOL, HVAC_MODE_OFF, - CURRENT_HVAC_IDLE, - CURRENT_HVAC_HEAT, - CURRENT_HVAC_COOL, - SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_HUMIDITY, + SUPPORT_TARGET_TEMPERATURE, ) from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS diff --git a/homeassistant/components/homekit_controller/config_flow.py b/homeassistant/components/homekit_controller/config_flow.py index 40bf87d6f0a..f4eb1190727 100644 --- a/homeassistant/components/homekit_controller/config_flow.py +++ b/homeassistant/components/homekit_controller/config_flow.py @@ -1,17 +1,17 @@ """Config flow to configure homekit_controller.""" -import os import json import logging +import os import homekit +from homekit.controller.ip_implementation import IpPairing import voluptuous as vol from homeassistant import config_entries from homeassistant.core import callback +from .connection import get_accessory_name, get_bridge_information from .const import DOMAIN, KNOWN_DEVICES -from .connection import get_bridge_information, get_accessory_name - HOMEKIT_IGNORE = ["Home Assistant Bridge"] HOMEKIT_DIR = ".homekit" @@ -194,7 +194,6 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow): async def async_import_legacy_pairing(self, discovery_props, pairing_data): """Migrate a legacy pairing to config entries.""" - from homekit.controller.ip_implementation import IpPairing hkid = discovery_props["id"] diff --git a/homeassistant/components/homekit_controller/connection.py b/homeassistant/components/homekit_controller/connection.py index 1cb2131fb8f..3ccfa8b0139 100644 --- a/homeassistant/components/homekit_controller/connection.py +++ b/homeassistant/components/homekit_controller/connection.py @@ -3,18 +3,18 @@ import asyncio import datetime import logging +from homekit.controller.ip_implementation import IpPairing from homekit.exceptions import ( AccessoryDisconnectedError, AccessoryNotFoundError, EncryptionError, ) -from homekit.model.services import ServicesTypes from homekit.model.characteristics import CharacteristicsTypes +from homekit.model.services import ServicesTypes from homeassistant.helpers.event import async_track_time_interval -from .const import DOMAIN, HOMEKIT_ACCESSORY_DISPATCH, ENTITY_MAP - +from .const import DOMAIN, ENTITY_MAP, HOMEKIT_ACCESSORY_DISPATCH DEFAULT_SCAN_INTERVAL = datetime.timedelta(seconds=60) RETRY_INTERVAL = 60 # seconds @@ -57,7 +57,6 @@ class HKDevice: def __init__(self, hass, config_entry, pairing_data): """Initialise a generic HomeKit device.""" - from homekit.controller.ip_implementation import IpPairing self.hass = hass self.config_entry = config_entry diff --git a/homeassistant/components/homekit_controller/cover.py b/homeassistant/components/homekit_controller/cover.py index 0606778acb5..7e5591d9505 100644 --- a/homeassistant/components/homekit_controller/cover.py +++ b/homeassistant/components/homekit_controller/cover.py @@ -11,8 +11,8 @@ from homeassistant.components.cover import ( SUPPORT_OPEN, SUPPORT_OPEN_TILT, SUPPORT_SET_POSITION, - SUPPORT_STOP, SUPPORT_SET_TILT_POSITION, + SUPPORT_STOP, CoverDevice, ) from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPEN, STATE_OPENING diff --git a/homeassistant/components/homekit_controller/storage.py b/homeassistant/components/homekit_controller/storage.py index 46d095b5631..ffc2da5fbf2 100644 --- a/homeassistant/components/homekit_controller/storage.py +++ b/homeassistant/components/homekit_controller/storage.py @@ -1,7 +1,7 @@ """Helpers for HomeKit data stored in HA storage.""" -from homeassistant.helpers.storage import Store from homeassistant.core import callback +from homeassistant.helpers.storage import Store from .const import DOMAIN diff --git a/tests/components/homekit_controller/common.py b/tests/components/homekit_controller/common.py index 2e1cfd7a77d..9a404701c54 100644 --- a/tests/components/homekit_controller/common.py +++ b/tests/components/homekit_controller/common.py @@ -250,7 +250,7 @@ async def setup_test_accessories(hass, accessories): config_entry.add_to_hass(hass) - pairing_cls_loc = "homekit.controller.ip_implementation.IpPairing" + pairing_cls_loc = "homeassistant.components.homekit_controller.connection.IpPairing" with mock.patch(pairing_cls_loc) as pairing_cls: pairing_cls.return_value = pairing await config_entry.async_setup(hass) diff --git a/tests/components/homekit_controller/specific_devices/test_ecobee3.py b/tests/components/homekit_controller/specific_devices/test_ecobee3.py index 8473d235278..8531712a5d3 100644 --- a/tests/components/homekit_controller/specific_devices/test_ecobee3.py +++ b/tests/components/homekit_controller/specific_devices/test_ecobee3.py @@ -154,7 +154,7 @@ async def test_ecobee3_setup_connection_failure(hass): # make sure the IpPairing mock is in place or we'll try to connect to # a real device. Normally this mocking is done by the helper in # setup_test_accessories. - pairing_cls_loc = "homekit.controller.ip_implementation.IpPairing" + pairing_cls_loc = "homeassistant.components.homekit_controller.connection.IpPairing" with mock.patch(pairing_cls_loc) as pairing_cls: pairing_cls.return_value = pairing await time_changed(hass, 5 * 60) diff --git a/tests/components/homekit_controller/test_config_flow.py b/tests/components/homekit_controller/test_config_flow.py index a8428375ae6..81d5ac9a751 100644 --- a/tests/components/homekit_controller/test_config_flow.py +++ b/tests/components/homekit_controller/test_config_flow.py @@ -554,7 +554,9 @@ async def test_import_works(hass): flow = _setup_flow_handler(hass) - pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing" + pairing_cls_imp = ( + "homeassistant.components.homekit_controller.config_flow.IpPairing" + ) with mock.patch(pairing_cls_imp) as pairing_cls: pairing_cls.return_value = pairing @@ -694,7 +696,9 @@ async def test_parse_new_homekit_json(hass): flow = _setup_flow_handler(hass) - pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing" + pairing_cls_imp = ( + "homeassistant.components.homekit_controller.config_flow.IpPairing" + ) with mock.patch(pairing_cls_imp) as pairing_cls: pairing_cls.return_value = pairing @@ -742,7 +746,9 @@ async def test_parse_old_homekit_json(hass): flow = _setup_flow_handler(hass) - pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing" + pairing_cls_imp = ( + "homeassistant.components.homekit_controller.config_flow.IpPairing" + ) with mock.patch(pairing_cls_imp) as pairing_cls: pairing_cls.return_value = pairing @@ -798,7 +804,9 @@ async def test_parse_overlapping_homekit_json(hass): flow = _setup_flow_handler(hass) - pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing" + pairing_cls_imp = ( + "homeassistant.components.homekit_controller.config_flow.IpPairing" + ) with mock.patch(pairing_cls_imp) as pairing_cls: pairing_cls.return_value = pairing