mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 16:17:20 +00:00
update comments
This commit is contained in:
parent
8617b92d1b
commit
7c925ac295
@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.rpi_gpio
|
homeassistant.components.binary_sensor.rpi_gpio
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Allows to configure a binary_sensor state sensor using RPi GPIO.
|
Allows to configure a binary_sensor using RPi GPIO.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/binary_sensor.rpi_gpio/
|
https://home-assistant.io/components/binary_sensor.rpi_gpio/
|
||||||
@ -22,7 +22,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the Raspberry PI GPIO ports. """
|
""" Sets up the Raspberry PI GPIO devices. """
|
||||||
|
|
||||||
pull_mode = config.get('pull_mode', DEFAULT_PULL_MODE)
|
pull_mode = config.get('pull_mode', DEFAULT_PULL_MODE)
|
||||||
bouncetime = config.get('bouncetime', DEFAULT_BOUNCETIME)
|
bouncetime = config.get('bouncetime', DEFAULT_BOUNCETIME)
|
||||||
@ -38,7 +38,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||||
class RPiGPIOBinarySensor(Entity):
|
class RPiGPIOBinarySensor(Entity):
|
||||||
""" Sets up the Raspberry PI GPIO ports. """
|
""" Represents a binary sensor that uses Raspberry Pi GPIO. """
|
||||||
def __init__(self, name, port, pull_mode, bouncetime, invert_logic):
|
def __init__(self, name, port, pull_mode, bouncetime, invert_logic):
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
|
|
||||||
|
@ -4,8 +4,9 @@ homeassistant.components.switch.rpi_gpio
|
|||||||
Allows to control the GPIO pins of a Raspberry Pi.
|
Allows to control the GPIO pins of a Raspberry Pi.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/switch.rpi_gpio/
|
https://home-assistant.io/components/rpi_gpio/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
try:
|
try:
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
@ -20,7 +21,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
""" Sets up the Raspberry PI GPIO ports. """
|
""" Sets up the Raspberry PI GPIO component. """
|
||||||
if GPIO is None:
|
if GPIO is None:
|
||||||
_LOGGER.error('RPi.GPIO not available. rpi_gpio ports ignored.')
|
_LOGGER.error('RPi.GPIO not available. rpi_gpio ports ignored.')
|
||||||
return False
|
return False
|
||||||
@ -39,28 +40,28 @@ def setup(hass, config):
|
|||||||
|
|
||||||
|
|
||||||
def setup_output(port):
|
def setup_output(port):
|
||||||
""" Setup a GPIO as output """
|
""" Setup a GPIO as output. """
|
||||||
GPIO.setup(port, GPIO.OUT)
|
GPIO.setup(port, GPIO.OUT)
|
||||||
|
|
||||||
|
|
||||||
def setup_input(port, pull_mode):
|
def setup_input(port, pull_mode):
|
||||||
""" Setup a GPIO as input """
|
""" Setup a GPIO as input. """
|
||||||
GPIO.setup(port, GPIO.IN,
|
GPIO.setup(port, GPIO.IN,
|
||||||
GPIO.PUD_DOWN if pull_mode == 'DOWN' else GPIO.PUD_UP)
|
GPIO.PUD_DOWN if pull_mode == 'DOWN' else GPIO.PUD_UP)
|
||||||
|
|
||||||
|
|
||||||
def write_output(port, value):
|
def write_output(port, value):
|
||||||
""" Write a value to a GPIO"""
|
""" Write a value to a GPIO. """
|
||||||
GPIO.output(port, value)
|
GPIO.output(port, value)
|
||||||
|
|
||||||
|
|
||||||
def read_input(port):
|
def read_input(port):
|
||||||
""" Read a value from a GPIO"""
|
""" Read a value from a GPIO. """
|
||||||
return GPIO.input(port)
|
return GPIO.input(port)
|
||||||
|
|
||||||
|
|
||||||
def edge_detect(port, event_callback, bounce):
|
def edge_detect(port, event_callback, bounce):
|
||||||
""" Adds detection for RISING and FALLING events """
|
""" Adds detection for RISING and FALLING events. """
|
||||||
GPIO.add_event_detect(
|
GPIO.add_event_detect(
|
||||||
port,
|
port,
|
||||||
GPIO.BOTH,
|
GPIO.BOTH,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.sensor.rpi_gpio
|
homeassistant.components.sensor.rpi_gpio
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Allows to configure a binary state sensor using RPi GPIO.
|
Allows to configure a sensor using RPi GPIO.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/sensor.rpi_gpio/
|
https://home-assistant.io/components/sensor.rpi_gpio/
|
||||||
@ -21,7 +21,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the Raspberry PI GPIO ports. """
|
""" Sets up the Raspberry PI GPIO devices. """
|
||||||
|
|
||||||
pull_mode = config.get('pull_mode', DEFAULT_PULL_MODE)
|
pull_mode = config.get('pull_mode', DEFAULT_PULL_MODE)
|
||||||
bouncetime = config.get('bouncetime', DEFAULT_BOUNCETIME)
|
bouncetime = config.get('bouncetime', DEFAULT_BOUNCETIME)
|
||||||
@ -39,7 +39,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||||
class RPiGPIOSensor(RPiGPIOBinarySensor):
|
class RPiGPIOSensor(RPiGPIOBinarySensor):
|
||||||
""" Sets up the Raspberry PI GPIO ports. """
|
""" Represents a sensor that uses Raspberry Pi GPIO. """
|
||||||
def __init__(self, name, port, pull_mode, bouncetime,
|
def __init__(self, name, port, pull_mode, bouncetime,
|
||||||
value_high, value_low):
|
value_high, value_low):
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.switch.rpi_gpio
|
homeassistant.components.switch.rpi_gpio
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Allows to control the GPIO pins of a Raspberry Pi.
|
Allows to configure a switch using RPi GPIO.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/switch.rpi_gpio/
|
https://home-assistant.io/components/switch.rpi_gpio/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import homeassistant.components.rpi_gpio as rpi_gpio
|
import homeassistant.components.rpi_gpio as rpi_gpio
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
@ -19,7 +20,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the Raspberry PI GPIO ports. """
|
""" Sets up the Raspberry PI GPIO devices. """
|
||||||
|
|
||||||
invert_logic = config.get('invert_logic', DEFAULT_INVERT_LOGIC)
|
invert_logic = config.get('invert_logic', DEFAULT_INVERT_LOGIC)
|
||||||
|
|
||||||
@ -31,8 +32,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
|
|
||||||
class RPiGPIOSwitch(ToggleEntity):
|
class RPiGPIOSwitch(ToggleEntity):
|
||||||
""" Represents a port that can be toggled using Raspberry Pi GPIO. """
|
""" Represents a switch that can be toggled using Raspberry Pi GPIO. """
|
||||||
|
|
||||||
def __init__(self, name, port, invert_logic):
|
def __init__(self, name, port, invert_logic):
|
||||||
self._name = name or DEVICE_DEFAULT_NAME
|
self._name = name or DEVICE_DEFAULT_NAME
|
||||||
self._port = port
|
self._port = port
|
||||||
@ -42,7 +42,7 @@ class RPiGPIOSwitch(ToggleEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" The name of the port. """
|
""" The name of the switch. """
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user