mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Move imports in rpi_pfio component (#28094)
This commit is contained in:
parent
828bf1b400
commit
4a3d6208ae
@ -1,6 +1,8 @@
|
|||||||
"""Support for controlling the PiFace Digital I/O module on a RPi."""
|
"""Support for controlling the PiFace Digital I/O module on a RPi."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import pifacedigitalio as PFIO
|
||||||
|
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -12,8 +14,6 @@ DATA_PFIO_LISTENER = "pfio_listener"
|
|||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Set up the Raspberry PI PFIO component."""
|
"""Set up the Raspberry PI PFIO component."""
|
||||||
import pifacedigitalio as PFIO
|
|
||||||
|
|
||||||
pifacedigital = PFIO.PiFaceDigital()
|
pifacedigital = PFIO.PiFaceDigital()
|
||||||
hass.data[DATA_PFIO_LISTENER] = PFIO.InputEventListener(chip=pifacedigital)
|
hass.data[DATA_PFIO_LISTENER] = PFIO.InputEventListener(chip=pifacedigital)
|
||||||
|
|
||||||
@ -33,22 +33,16 @@ def setup(hass, config):
|
|||||||
|
|
||||||
def write_output(port, value):
|
def write_output(port, value):
|
||||||
"""Write a value to a PFIO."""
|
"""Write a value to a PFIO."""
|
||||||
import pifacedigitalio as PFIO
|
|
||||||
|
|
||||||
PFIO.digital_write(port, value)
|
PFIO.digital_write(port, value)
|
||||||
|
|
||||||
|
|
||||||
def read_input(port):
|
def read_input(port):
|
||||||
"""Read a value from a PFIO."""
|
"""Read a value from a PFIO."""
|
||||||
import pifacedigitalio as PFIO
|
|
||||||
|
|
||||||
return PFIO.digital_read(port)
|
return PFIO.digital_read(port)
|
||||||
|
|
||||||
|
|
||||||
def edge_detect(hass, port, event_callback, settle):
|
def edge_detect(hass, port, event_callback, settle):
|
||||||
"""Add detection for RISING and FALLING events."""
|
"""Add detection for RISING and FALLING events."""
|
||||||
import pifacedigitalio as PFIO
|
|
||||||
|
|
||||||
hass.data[DATA_PFIO_LISTENER].register(
|
hass.data[DATA_PFIO_LISTENER].register(
|
||||||
port, PFIO.IODIR_BOTH, event_callback, settle_time=settle
|
port, PFIO.IODIR_BOTH, event_callback, settle_time=settle
|
||||||
)
|
)
|
||||||
|
@ -3,8 +3,8 @@ import logging
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
|
|
||||||
from homeassistant.components import rpi_pfio
|
from homeassistant.components import rpi_pfio
|
||||||
|
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
|
||||||
from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME
|
from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user