Allow generating requirements_all.txt

This commit is contained in:
Paulus Schoutsen committed 2015-11-17 00:21:49 -08:00
1 parent 8be53af78f
commit 377d2c6e5a
17 files changed
+283 -206

No files matched your search

@@ -11,12 +11,6 @@ from homeassistant.const import STATE_ON, STATE_OFF
from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD
import logging
try:
import hikvision.api
from hikvision.error import HikvisionError, MissingParamError
except ImportError:
hikvision.api = None
_LOGGING = logging.getLogger(__name__)
REQUIREMENTS = ['hikvision==0.4']
# pylint: disable=too-many-arguments
@@ -25,6 +19,8 @@ REQUIREMENTS = ['hikvision==0.4']
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Setup Hikvision camera. """
import hikvision.api
from hikvision.error import HikvisionError, MissingParamError
host = config.get(CONF_HOST, None)
port = config.get('port', "80")
@@ -32,13 +28,6 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
username = config.get(CONF_USERNAME, "admin")
password = config.get(CONF_PASSWORD, "12345")
if hikvision.api is None:
_LOGGING.error((
"Failed to import hikvision. Did you maybe not install the "
"'hikvision' dependency?"))
return False
try:
hikvision_cam = hikvision.api.CreateDevice(
host, port=port, username=username,
+8 -5
View File
@@ -10,8 +10,6 @@ import logging
from homeassistant.components.switch import SwitchDevice
from orvibo.s20 import S20, S20Exception
DEFAULT_NAME = "Orvibo S20 Switch"
REQUIREMENTS = ['orvibo==1.0.0']
_LOGGER = logging.getLogger(__name__)
@@ -20,6 +18,8 @@ _LOGGER = logging.getLogger(__name__)
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Find and return S20 switches. """
from orvibo.s20 import S20, S20Exception
if config.get('host') is None:
_LOGGER.error("Missing required variable: host")
return
@@ -34,9 +34,12 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class S20Switch(SwitchDevice):
""" Represents an S20 switch. """
def __init__(self, name, s20):
from orvibo.s20 import S20Exception
self._name = name
self._s20 = s20
self._state = False
self._exc = S20Exception
@property
def should_poll(self):
@@ -57,19 +60,19 @@ class S20Switch(SwitchDevice):
""" Update device state. """
try:
self._state = self._s20.on
except S20Exception:
except self._exc:
_LOGGER.exception("Error while fetching S20 state")
def turn_on(self, **kwargs):
""" Turn the device on. """
try:
self._s20.on = True
except S20Exception:
except self._exc:
_LOGGER.exception("Error while turning on S20")
def turn_off(self, **kwargs):
""" Turn the device off. """
try:
self._s20.on = False
except S20Exception:
except self._exc:
_LOGGER.exception("Error while turning off S20")
+1 -1
View File
@@ -8,7 +8,6 @@ https://home-assistant.io/components/switch.rfxtrx/
"""
import logging
import homeassistant.components.rfxtrx as rfxtrx
from RFXtrx import LightingDevice
from homeassistant.components.switch import SwitchDevice
from homeassistant.util import slugify
@@ -20,6 +19,7 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Setup the RFXtrx platform. """
from RFXtrx import LightingDevice
# Add switch from config file
switchs = []
+10 -9
View File
@@ -11,8 +11,6 @@ import logging
from homeassistant.const import (EVENT_HOMEASSISTANT_STOP,
ATTR_FRIENDLY_NAME)
from homeassistant.helpers.entity import ToggleEntity
import tellcore.constants as tellcore_constants
from tellcore.library import DirectCallbackDispatcher
SIGNAL_REPETITIONS = 1
REQUIREMENTS = ['tellcore-py==1.1.2']
@@ -22,11 +20,9 @@ _LOGGER = logging.getLogger(__name__)
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Find and return Tellstick switches. """
try:
import tellcore.telldus as telldus
except ImportError:
_LOGGER.exception("Failed to import tellcore")
return
import tellcore.telldus as telldus
import tellcore.constants as tellcore_constants
from tellcore.library import DirectCallbackDispatcher
core = telldus.TelldusCore(callback_dispatcher=DirectCallbackDispatcher())
@@ -62,14 +58,17 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class TellstickSwitchDevice(ToggleEntity):
""" Represents a Tellstick switch. """
last_sent_command_mask = (tellcore_constants.TELLSTICK_TURNON |
tellcore_constants.TELLSTICK_TURNOFF)
def __init__(self, tellstick_device, signal_repetitions):
import tellcore.constants as tellcore_constants
self.tellstick_device = tellstick_device
self.state_attr = {ATTR_FRIENDLY_NAME: tellstick_device.name}
self.signal_repetitions = signal_repetitions
self.last_sent_command_mask = (tellcore_constants.TELLSTICK_TURNON |
tellcore_constants.TELLSTICK_TURNOFF)
@property
def should_poll(self):
""" Tells Home Assistant not to poll this entity. """
@@ -88,6 +87,8 @@ class TellstickSwitchDevice(ToggleEntity):
@property
def is_on(self):
""" True if switch is on. """
import tellcore.constants as tellcore_constants
last_command = self.tellstick_device.last_sent_command(
self.last_sent_command_mask)
@@ -10,9 +10,6 @@ from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD
from homeassistant.const import STATE_ON, STATE_OFF
from homeassistant.helpers.entity import ToggleEntity
# pylint: disable=no-name-in-module, import-error
import transmissionrpc
from transmissionrpc.error import TransmissionError
import logging
_LOGGING = logging.getLogger(__name__)
@@ -22,6 +19,9 @@ REQUIREMENTS = ['transmissionrpc==0.11']
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Sets up the transmission sensor. """
import transmissionrpc
from transmissionrpc.error import TransmissionError
host = config.get(CONF_HOST)
username = config.get(CONF_USERNAME, None)
password = config.get(CONF_PASSWORD, None)
+3 -3
View File
@@ -5,8 +5,6 @@ homeassistant.components.switch.zwave
Zwave platform that handles simple binary switches.
"""
# pylint: disable=import-error
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher
import homeassistant.components.zwave as zwave
@@ -36,11 +34,13 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class ZwaveSwitch(SwitchDevice):
""" Provides a zwave switch. """
def __init__(self, value):
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher
self._value = value
self._node = value.node
self._state = value.data
dispatcher.connect(
self._value_changed, ZWaveNetwork.SIGNAL_VALUE_CHANGED)