Move imports to top for recswitch (#29285)

This commit is contained in:
springstan 2019-12-01 15:24:48 +01:00 committed by Martin Hjelmare
parent d0ed9b32ac
commit a0a348a200

View File

@ -2,13 +2,13 @@
import logging import logging
from pyrecswitch import RSNetwork, RSNetworkError
import voluptuous as vol import voluptuous as vol
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = "RecSwitch {0}" DEFAULT_NAME = "RecSwitch {0}"
@ -26,7 +26,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the device.""" """Set up the device."""
from pyrecswitch import RSNetwork
host = config[CONF_HOST] host = config[CONF_HOST]
mac_address = config[CONF_MAC] mac_address = config[CONF_MAC]
@ -78,7 +77,6 @@ class RecSwitchSwitch(SwitchDevice):
async def async_set_gpio_status(self, status): async def async_set_gpio_status(self, status):
"""Set the switch status.""" """Set the switch status."""
from pyrecswitch import RSNetworkError
try: try:
ret = await self.device.set_gpio_status(status) ret = await self.device.set_gpio_status(status)
@ -88,7 +86,6 @@ class RecSwitchSwitch(SwitchDevice):
async def async_update(self): async def async_update(self):
"""Update the current switch status.""" """Update the current switch status."""
from pyrecswitch import RSNetworkError
try: try:
ret = await self.device.get_gpio_status() ret = await self.device.get_gpio_status()