From 05a770a8a14461de409507b047b48c43fde9a226 Mon Sep 17 00:00:00 2001 From: springstan Date: Wed, 4 Dec 2019 16:58:54 +0100 Subject: [PATCH] Move imports to top for deluge --- homeassistant/components/deluge/sensor.py | 13 ++++++------- homeassistant/components/deluge/switch.py | 9 ++++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/deluge/sensor.py b/homeassistant/components/deluge/sensor.py index 098484cf7ae6e2..7df87490c60930 100644 --- a/homeassistant/components/deluge/sensor.py +++ b/homeassistant/components/deluge/sensor.py @@ -1,21 +1,22 @@ """Support for monitoring the Deluge BitTorrent client API.""" import logging +from deluge_client import DelugeRPCClient, FailedToReconnectException import voluptuous as vol -import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_HOST, - CONF_PASSWORD, - CONF_USERNAME, + CONF_MONITORED_VARIABLES, CONF_NAME, + CONF_PASSWORD, CONF_PORT, - CONF_MONITORED_VARIABLES, + CONF_USERNAME, STATE_IDLE, ) -from homeassistant.helpers.entity import Entity from homeassistant.exceptions import PlatformNotReady +import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) _THROTTLED_REFRESH = None @@ -46,7 +47,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Deluge sensors.""" - from deluge_client import DelugeRPCClient name = config.get(CONF_NAME) host = config.get(CONF_HOST) @@ -103,7 +103,6 @@ def unit_of_measurement(self): def update(self): """Get the latest data from Deluge and updates the state.""" - from deluge_client import FailedToReconnectException try: self.data = self.client.call( diff --git a/homeassistant/components/deluge/switch.py b/homeassistant/components/deluge/switch.py index 981ef129b473b3..7ac98f284c8a99 100644 --- a/homeassistant/components/deluge/switch.py +++ b/homeassistant/components/deluge/switch.py @@ -1,21 +1,22 @@ """Support for setting the Deluge BitTorrent client in Pause.""" import logging +from deluge_client import DelugeRPCClient, FailedToReconnectException import voluptuous as vol from homeassistant.components.switch import PLATFORM_SCHEMA -from homeassistant.exceptions import PlatformNotReady from homeassistant.const import ( CONF_HOST, CONF_NAME, - CONF_PORT, CONF_PASSWORD, + CONF_PORT, CONF_USERNAME, STATE_OFF, STATE_ON, ) -from homeassistant.helpers.entity import ToggleEntity +from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.entity import ToggleEntity _LOGGER = logging.getLogger(__name__) @@ -35,7 +36,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Deluge switch.""" - from deluge_client import DelugeRPCClient name = config.get(CONF_NAME) host = config.get(CONF_HOST) @@ -95,7 +95,6 @@ def turn_off(self, **kwargs): def update(self): """Get the latest data from deluge and updates the state.""" - from deluge_client import FailedToReconnectException try: torrent_list = self.deluge_client.call(