remove rpi_gpio sensor

pull/899/head
sfam 2016-01-15 18:05:48 +00:00
parent 702dddbb2f
commit d8d59d9a66
3 changed files with 5 additions and 61 deletions

View File

@ -10,7 +10,7 @@ https://home-assistant.io/components/binary_sensor.rpi_gpio/
import logging
import homeassistant.components.rpi_gpio as rpi_gpio
from homeassistant.helpers.entity import Entity
from homeassistant.const import (STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME)
from homeassistant.const import (DEVICE_DEFAULT_NAME)
DEFAULT_PULL_MODE = "UP"
DEFAULT_BOUNCETIME = 50
@ -37,7 +37,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-many-arguments, too-many-instance-attributes
class RPiGPIOBinarySensor(Entity):
class RPiGPIOBinarySensor(BinarySensorDevice):
""" Represents a binary sensor that uses Raspberry Pi GPIO. """
def __init__(self, name, port, pull_mode, bouncetime, invert_logic):
# pylint: disable=no-member
@ -68,6 +68,6 @@ class RPiGPIOBinarySensor(Entity):
return self._name
@property
def state(self):
def is_on(self):
""" Returns the state of the entity. """
return STATE_ON if self._state != self._invert_logic else STATE_OFF
return self._state != self._invert_logic

View File

@ -1,5 +1,5 @@
"""
homeassistant.components.switch.rpi_gpio
homeassistant.components.rpi_gpio
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to control the GPIO pins of a Raspberry Pi.

View File

@ -1,56 +0,0 @@
"""
homeassistant.components.sensor.rpi_gpio
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to configure a sensor using RPi GPIO.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.rpi_gpio/
"""
import logging
from homeassistant.components.binary_sensor.rpi_gpio import RPiGPIOBinarySensor
DEFAULT_PULL_MODE = "UP"
DEFAULT_BOUNCETIME = 50
DEFAULT_VALUE_HIGH = "HIGH"
DEFAULT_VALUE_LOW = "LOW"
DEPENDENCIES = ['rpi_gpio']
_LOGGER = logging.getLogger(__name__)
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Raspberry PI GPIO devices. """
pull_mode = config.get('pull_mode', DEFAULT_PULL_MODE)
bouncetime = config.get('bouncetime', DEFAULT_BOUNCETIME)
value_high = config.get('value_high', DEFAULT_VALUE_HIGH)
value_low = config.get('value_low', DEFAULT_VALUE_LOW)
sensors = []
ports = config.get('ports')
for port, name in ports.items():
sensors.append(RPiGPIOSensor(
name, port, pull_mode, bouncetime,
value_high, value_low))
add_devices(sensors)
# pylint: disable=too-many-arguments, too-many-instance-attributes
class RPiGPIOSensor(RPiGPIOBinarySensor):
""" Represents a sensor that uses Raspberry Pi GPIO. """
def __init__(self, name, port, pull_mode, bouncetime,
value_high, value_low):
self._value_high = value_high
self._value_low = value_low
super().__init__(name, port, pull_mode, bouncetime, False)
@property
def state(self):
""" Returns the state of the entity. """
if self._state != self._invert_logic:
return self._value_high
else:
return self._value_low