Move imports in rpi_pfio component (#28094)
This commit is contained in:
parent
828bf1b400
commit
4a3d6208ae
2 changed files with 3 additions and 9 deletions
|
@ -1,6 +1,8 @@
|
|||
"""Support for controlling the PiFace Digital I/O module on a RPi."""
|
||||
import logging
|
||||
|
||||
import pifacedigitalio as PFIO
|
||||
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -12,8 +14,6 @@ DATA_PFIO_LISTENER = "pfio_listener"
|
|||
|
||||
def setup(hass, config):
|
||||
"""Set up the Raspberry PI PFIO component."""
|
||||
import pifacedigitalio as PFIO
|
||||
|
||||
pifacedigital = PFIO.PiFaceDigital()
|
||||
hass.data[DATA_PFIO_LISTENER] = PFIO.InputEventListener(chip=pifacedigital)
|
||||
|
||||
|
@ -33,22 +33,16 @@ def setup(hass, config):
|
|||
|
||||
def write_output(port, value):
|
||||
"""Write a value to a PFIO."""
|
||||
import pifacedigitalio as PFIO
|
||||
|
||||
PFIO.digital_write(port, value)
|
||||
|
||||
|
||||
def read_input(port):
|
||||
"""Read a value from a PFIO."""
|
||||
import pifacedigitalio as PFIO
|
||||
|
||||
return PFIO.digital_read(port)
|
||||
|
||||
|
||||
def edge_detect(hass, port, event_callback, settle):
|
||||
"""Add detection for RISING and FALLING events."""
|
||||
import pifacedigitalio as PFIO
|
||||
|
||||
hass.data[DATA_PFIO_LISTENER].register(
|
||||
port, PFIO.IODIR_BOTH, event_callback, settle_time=settle
|
||||
)
|
||||
|
|
|
@ -3,8 +3,8 @@ import logging
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
|
||||
from homeassistant.components import rpi_pfio
|
||||
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
|
||||
from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue