Move imports to top for deluge (#29438)

This commit is contained in:
springstan 2019-12-05 06:23:56 +01:00 committed by Paulus Schoutsen
parent 4c0f73a2b9
commit 69ae469148
2 changed files with 11 additions and 13 deletions

View File

@ -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_NAME,
CONF_PORT,
CONF_MONITORED_VARIABLES,
CONF_NAME,
CONF_PASSWORD,
CONF_PORT,
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 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
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 @@ class DelugeSensor(Entity):
def update(self):
"""Get the latest data from Deluge and updates the state."""
from deluge_client import FailedToReconnectException
try:
self.data = self.client.call(

View File

@ -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 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
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 @@ class DelugeSwitch(ToggleEntity):
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(