Move imports in wink component (#27392)
This commit is contained in:
parent
7b13f0caf7
commit
91379b0ff7
11 changed files with 24 additions and 18 deletions
|
@ -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):
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"]:
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue