Move imports in rpi_gpio (#27752)
* move imports for rpi_gpio * fixed pylint error * fix pylint error * removed empty line * add missing blank line * sort with isortpull/27776/head
parent
7fd606a254
commit
b187ca93d0
homeassistant/components/rpi_gpio
|
@ -1,6 +1,8 @@
|
|||
"""Support for controlling GPIO pins of a Raspberry Pi."""
|
||||
import logging
|
||||
|
||||
from RPi import GPIO # pylint: disable=import-error
|
||||
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -10,7 +12,6 @@ DOMAIN = "rpi_gpio"
|
|||
|
||||
def setup(hass, config):
|
||||
"""Set up the Raspberry PI GPIO component."""
|
||||
from RPi import GPIO # pylint: disable=import-error
|
||||
|
||||
def cleanup_gpio(event):
|
||||
"""Stuff to do before stopping."""
|
||||
|
@ -27,34 +28,24 @@ def setup(hass, config):
|
|||
|
||||
def setup_output(port):
|
||||
"""Set up a GPIO as output."""
|
||||
from RPi import GPIO # pylint: disable=import-error
|
||||
|
||||
GPIO.setup(port, GPIO.OUT)
|
||||
|
||||
|
||||
def setup_input(port, pull_mode):
|
||||
"""Set up a GPIO as input."""
|
||||
from RPi import GPIO # pylint: disable=import-error
|
||||
|
||||
GPIO.setup(port, GPIO.IN, GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP)
|
||||
|
||||
|
||||
def write_output(port, value):
|
||||
"""Write a value to a GPIO."""
|
||||
from RPi import GPIO # pylint: disable=import-error
|
||||
|
||||
GPIO.output(port, value)
|
||||
|
||||
|
||||
def read_input(port):
|
||||
"""Read a value from a GPIO."""
|
||||
from RPi import GPIO # pylint: disable=import-error
|
||||
|
||||
return GPIO.input(port)
|
||||
|
||||
|
||||
def edge_detect(port, event_callback, bounce):
|
||||
"""Add detection for RISING and FALLING events."""
|
||||
from RPi import GPIO # pylint: disable=import-error
|
||||
|
||||
GPIO.add_event_detect(port, GPIO.BOTH, callback=event_callback, bouncetime=bounce)
|
||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import rpi_gpio
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice, PLATFORM_SCHEMA
|
||||
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
|
||||
from homeassistant.const import DEVICE_DEFAULT_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ from time import sleep
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.cover import CoverDevice, PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.components import rpi_gpio
|
||||
from homeassistant.components.cover import PLATFORM_SCHEMA, CoverDevice
|
||||
from homeassistant.const import CONF_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
|
Loading…
Reference in New Issue