diff --git a/homeassistant/components/wink/__init__.py b/homeassistant/components/wink/__init__.py index d0bb27c06e1..e2eb98938bb 100644 --- a/homeassistant/components/wink/__init__.py +++ b/homeassistant/components/wink/__init__.py @@ -5,6 +5,9 @@ import logging import os import time +from aiohttp.web import Response +import pywink +from pubnubsubhandler import PubNubSubscriptionHandler import voluptuous as vol from homeassistant.components.http import HomeAssistantView @@ -279,8 +282,6 @@ def _request_oauth_completion(hass, config): def setup(hass, config): """Set up the Wink component.""" - import pywink - from pubnubsubhandler import PubNubSubscriptionHandler if hass.data.get(DOMAIN) is None: hass.data[DOMAIN] = { @@ -689,8 +690,6 @@ class WinkAuthCallbackView(HomeAssistantView): @callback def get(self, request): """Finish OAuth callback request.""" - from aiohttp import web - hass = request.app["hass"] data = request.query @@ -715,15 +714,13 @@ class WinkAuthCallbackView(HomeAssistantView): hass.async_add_job(setup, hass, self.config) - return web.Response( + return Response( text=html_response.format(response_message), content_type="text/html" ) error_msg = "No code returned from Wink API" _LOGGER.error(error_msg) - return web.Response( - text=html_response.format(error_msg), content_type="text/html" - ) + return Response(text=html_response.format(error_msg), content_type="text/html") class WinkDevice(Entity): diff --git a/homeassistant/components/wink/alarm_control_panel.py b/homeassistant/components/wink/alarm_control_panel.py index 4708b6efee8..654252f5ffe 100644 --- a/homeassistant/components/wink/alarm_control_panel.py +++ b/homeassistant/components/wink/alarm_control_panel.py @@ -1,6 +1,8 @@ """Support Wink alarm control panels.""" import logging +import pywink + import homeassistant.components.alarm_control_panel as alarm from homeassistant.const import ( STATE_ALARM_ARMED_AWAY, @@ -17,7 +19,6 @@ STATE_ALARM_PRIVACY = "Private" def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Wink platform.""" - import pywink for camera in pywink.get_cameras(): # get_cameras returns multiple device types. diff --git a/homeassistant/components/wink/binary_sensor.py b/homeassistant/components/wink/binary_sensor.py index e82a767fde8..6dd22a3f7b8 100644 --- a/homeassistant/components/wink/binary_sensor.py +++ b/homeassistant/components/wink/binary_sensor.py @@ -1,6 +1,8 @@ """Support for Wink binary sensors.""" import logging +import pywink + from homeassistant.components.binary_sensor import BinarySensorDevice from . import DOMAIN, WinkDevice @@ -26,7 +28,6 @@ SENSOR_TYPES = { def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Wink binary sensor platform.""" - import pywink for sensor in pywink.get_sensors(): _id = sensor.object_id() + sensor.name() diff --git a/homeassistant/components/wink/cover.py b/homeassistant/components/wink/cover.py index fa39909512a..1ce7f9b8875 100644 --- a/homeassistant/components/wink/cover.py +++ b/homeassistant/components/wink/cover.py @@ -1,4 +1,6 @@ """Support for Wink covers.""" +import pywink + from homeassistant.components.cover import ATTR_POSITION, CoverDevice from . import DOMAIN, WinkDevice @@ -6,7 +8,6 @@ from . import DOMAIN, WinkDevice def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Wink cover platform.""" - import pywink for shade in pywink.get_shades(): _id = shade.object_id() + shade.name() diff --git a/homeassistant/components/wink/fan.py b/homeassistant/components/wink/fan.py index 9f5f2f9b3a0..d1d4e30ada3 100644 --- a/homeassistant/components/wink/fan.py +++ b/homeassistant/components/wink/fan.py @@ -1,6 +1,8 @@ """Support for Wink fans.""" import logging +import pywink + from homeassistant.components.fan import ( SPEED_HIGH, SPEED_LOW, @@ -21,7 +23,6 @@ SUPPORTED_FEATURES = SUPPORT_DIRECTION + SUPPORT_SET_SPEED def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Wink platform.""" - import pywink for fan in pywink.get_fans(): if fan.object_id() + fan.name() not in hass.data[DOMAIN]["unique_ids"]: diff --git a/homeassistant/components/wink/light.py b/homeassistant/components/wink/light.py index 76576f804fa..bd125e6a7c2 100644 --- a/homeassistant/components/wink/light.py +++ b/homeassistant/components/wink/light.py @@ -1,4 +1,6 @@ """Support for Wink lights.""" +import pywink + from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, @@ -18,7 +20,6 @@ from . import DOMAIN, WinkDevice def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Wink lights.""" - import pywink for light in pywink.get_light_bulbs(): _id = light.object_id() + light.name() diff --git a/homeassistant/components/wink/lock.py b/homeassistant/components/wink/lock.py index 5246fb49eed..37b27c0d500 100644 --- a/homeassistant/components/wink/lock.py +++ b/homeassistant/components/wink/lock.py @@ -1,6 +1,7 @@ """Support for Wink locks.""" import logging +import pywink import voluptuous as vol from homeassistant.components.lock import LockDevice @@ -70,7 +71,6 @@ ADD_KEY_SCHEMA = vol.Schema( def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Wink platform.""" - import pywink for lock in pywink.get_locks(): _id = lock.object_id() + lock.name() diff --git a/homeassistant/components/wink/scene.py b/homeassistant/components/wink/scene.py index a00600ad784..ff083598b2e 100644 --- a/homeassistant/components/wink/scene.py +++ b/homeassistant/components/wink/scene.py @@ -1,6 +1,8 @@ """Support for Wink scenes.""" import logging +import pywink + from homeassistant.components.scene import Scene from . import DOMAIN, WinkDevice @@ -10,7 +12,6 @@ _LOGGER = logging.getLogger(__name__) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Wink platform.""" - import pywink for scene in pywink.get_scenes(): _id = scene.object_id() + scene.name() diff --git a/homeassistant/components/wink/sensor.py b/homeassistant/components/wink/sensor.py index 030a1e5b9ec..2d0313ec211 100644 --- a/homeassistant/components/wink/sensor.py +++ b/homeassistant/components/wink/sensor.py @@ -1,6 +1,8 @@ """Support for Wink sensors.""" import logging +import pywink + from homeassistant.const import TEMP_CELSIUS from . import DOMAIN, WinkDevice @@ -12,7 +14,6 @@ SENSOR_TYPES = ["temperature", "humidity", "balance", "proximity"] def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Wink platform.""" - import pywink for sensor in pywink.get_sensors(): _id = sensor.object_id() + sensor.name() diff --git a/homeassistant/components/wink/switch.py b/homeassistant/components/wink/switch.py index 07d3ff4becc..cf2264e7eeb 100644 --- a/homeassistant/components/wink/switch.py +++ b/homeassistant/components/wink/switch.py @@ -1,6 +1,8 @@ """Support for Wink switches.""" import logging +import pywink + from homeassistant.helpers.entity import ToggleEntity from . import DOMAIN, WinkDevice @@ -10,7 +12,6 @@ _LOGGER = logging.getLogger(__name__) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Wink platform.""" - import pywink for switch in pywink.get_switches(): _id = switch.object_id() + switch.name() diff --git a/homeassistant/components/wink/water_heater.py b/homeassistant/components/wink/water_heater.py index 4fceeeb313d..11330c7c9a5 100644 --- a/homeassistant/components/wink/water_heater.py +++ b/homeassistant/components/wink/water_heater.py @@ -1,6 +1,8 @@ """Support for Wink water heaters.""" import logging +import pywink + from homeassistant.components.water_heater import ( ATTR_TEMPERATURE, STATE_ECO, @@ -42,7 +44,6 @@ WINK_STATE_TO_HA = {value: key for key, value in HA_STATE_TO_WINK.items()} def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Wink water heater devices.""" - import pywink for water_heater in pywink.get_water_heaters(): _id = water_heater.object_id() + water_heater.name()