Move imports to top for remote_rpi_gpio (#29286)

pull/29297/head
springstan 2019-12-01 15:24:11 +01:00 committed by Martin Hjelmare
parent e2e53be5ac
commit d0ed9b32ac
3 changed files with 8 additions and 12 deletions

View File

@ -1,6 +1,9 @@
"""Support for controlling GPIO pins of a Raspberry Pi."""
import logging
from gpiozero import LED, Button
from gpiozero.pins.pigpio import PiGPIOFactory
_LOGGER = logging.getLogger(__name__)
CONF_BOUNCETIME = "bouncetime"
@ -21,8 +24,6 @@ def setup(hass, config):
def setup_output(address, port, invert_logic):
"""Set up a GPIO as output."""
from gpiozero import LED
from gpiozero.pins.pigpio import PiGPIOFactory
try:
return LED(port, active_high=invert_logic, pin_factory=PiGPIOFactory(address))
@ -32,8 +33,6 @@ def setup_output(address, port, invert_logic):
def setup_input(address, port, pull_mode, bouncetime):
"""Set up a GPIO as input."""
from gpiozero import Button
from gpiozero.pins.pigpio import PiGPIOFactory
if pull_mode == "UP":
pull_gpio_up = True

View File

@ -1,19 +1,17 @@
"""Support for binary sensor using RPi GPIO."""
import logging
import requests
import voluptuous as vol
import requests
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
from homeassistant.const import CONF_HOST
from homeassistant.components.binary_sensor import BinarySensorDevice, PLATFORM_SCHEMA
import homeassistant.helpers.config_validation as cv
from . import (
CONF_BOUNCETIME,
CONF_PULL_MODE,
CONF_INVERT_LOGIC,
CONF_PULL_MODE,
DEFAULT_BOUNCETIME,
DEFAULT_INVERT_LOGIC,
DEFAULT_PULL_MODE,

View File

@ -3,9 +3,8 @@ import logging
import voluptuous as vol
from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA
from homeassistant.const import DEVICE_DEFAULT_NAME, CONF_HOST
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice
from homeassistant.const import CONF_HOST, DEVICE_DEFAULT_NAME
import homeassistant.helpers.config_validation as cv
from . import CONF_INVERT_LOGIC, DEFAULT_INVERT_LOGIC