Skip to content

Commit

Permalink
Allow generating requirements_all.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Nov 17, 2015
1 parent 8be53af commit 377d2c6
Show file tree
Hide file tree
Showing 17 changed files with 248 additions and 171 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README.md
include README.rst
include LICENSE
graft homeassistant
prune homeassistant/components/frontend/www_static/home-assistant-polymer
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/light/blinksticklight.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"""
import logging

from blinkstick import blinkstick

from homeassistant.components.light import (Light, ATTR_RGB_COLOR)
from homeassistant.components.light import Light, ATTR_RGB_COLOR

_LOGGER = logging.getLogger(__name__)

Expand All @@ -22,6 +20,8 @@
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Add device specified by serial number. """
from blinkstick import blinkstick

stick = blinkstick.find_by_serial(config['serial'])

add_devices_callback([BlinkStickLight(stick, config['name'])])
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/light/rfxtrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""
import logging
import homeassistant.components.rfxtrx as rfxtrx
import RFXtrx as rfxtrxmod

from homeassistant.components.light import Light
from homeassistant.util import slugify
Expand All @@ -20,6 +19,8 @@

def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Setup the RFXtrx platform. """
import RFXtrx as rfxtrxmod

lights = []
devices = config.get('devices', None)
if devices:
Expand Down
28 changes: 13 additions & 15 deletions homeassistant/components/light/tellstick.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,19 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.tellstick/
"""
import logging
# pylint: disable=no-name-in-module, import-error
from homeassistant.components.light import Light, ATTR_BRIGHTNESS
from homeassistant.const import (EVENT_HOMEASSISTANT_STOP,
ATTR_FRIENDLY_NAME)
import tellcore.constants as tellcore_constants
from tellcore.library import DirectCallbackDispatcher
REQUIREMENTS = ['tellcore-py==1.1.2']


# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Find and return Tellstick lights. """

try:
import tellcore.telldus as telldus
except ImportError:
logging.getLogger(__name__).exception(
"Failed to import tellcore")
return []
import tellcore.telldus as telldus
from tellcore.library import DirectCallbackDispatcher
import tellcore.constants as tellcore_constants

core = telldus.TelldusCore(callback_dispatcher=DirectCallbackDispatcher())

Expand Down Expand Up @@ -58,17 +51,20 @@ def unload_telldus_lib(event):

class TellstickLight(Light):
""" Represents a Tellstick light. """
last_sent_command_mask = (tellcore_constants.TELLSTICK_TURNON |
tellcore_constants.TELLSTICK_TURNOFF |
tellcore_constants.TELLSTICK_DIM |
tellcore_constants.TELLSTICK_UP |
tellcore_constants.TELLSTICK_DOWN)

def __init__(self, tellstick_device):
import tellcore.constants as tellcore_constants

self.tellstick_device = tellstick_device
self.state_attr = {ATTR_FRIENDLY_NAME: tellstick_device.name}
self._brightness = 0

self.last_sent_command_mask = (tellcore_constants.TELLSTICK_TURNON |
tellcore_constants.TELLSTICK_TURNOFF |
tellcore_constants.TELLSTICK_DIM |
tellcore_constants.TELLSTICK_UP |
tellcore_constants.TELLSTICK_DOWN)

@property
def name(self):
""" Returns the name of the switch if any. """
Expand Down Expand Up @@ -104,6 +100,8 @@ def turn_on(self, **kwargs):

def update(self):
""" Update state of the light. """
import tellcore.constants as tellcore_constants

last_command = self.tellstick_device.last_sent_command(
self.last_sent_command_mask)

Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/light/zwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
https://home-assistant.io/components/light.zwave/
"""
# pylint: disable=import-error
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher

import homeassistant.components.zwave as zwave

from homeassistant.const import STATE_ON, STATE_OFF
Expand Down Expand Up @@ -51,6 +48,9 @@ class ZwaveDimmer(Light):
""" Provides a Z-Wave dimmer. """
# pylint: disable=too-many-arguments
def __init__(self, value):
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher

self._value = value
self._node = value.node

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/sensor/rfxtrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from homeassistant.const import (TEMP_CELCIUS)
from homeassistant.helpers.entity import Entity
from RFXtrx import SensorEvent
import homeassistant.components.rfxtrx as rfxtrx
from homeassistant.util import slugify

Expand All @@ -28,6 +27,7 @@

def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Setup the RFXtrx platform. """
from RFXtrx import SensorEvent

def sensor_update(event):
""" Callback for sensor updates from the RFXtrx gateway. """
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/sensor/tellstick.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import logging
from collections import namedtuple

import tellcore.telldus as telldus
import tellcore.constants as tellcore_constants

from homeassistant.const import TEMP_CELCIUS
from homeassistant.helpers.entity import Entity
import homeassistant.util as util
Expand All @@ -24,6 +21,9 @@
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up Tellstick sensors. """
import tellcore.telldus as telldus
import tellcore.constants as tellcore_constants

sensor_value_descriptions = {
tellcore_constants.TELLSTICK_TEMPERATURE:
DatatypeDescription(
Expand Down
9 changes: 5 additions & 4 deletions homeassistant/components/sensor/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD

from homeassistant.helpers.entity import Entity
# pylint: disable=no-name-in-module, import-error
import transmissionrpc

from transmissionrpc.error import TransmissionError

import logging

Expand All @@ -33,6 +29,9 @@
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Transmission sensors. """
import transmissionrpc
from transmissionrpc.error import TransmissionError

host = config.get(CONF_HOST)
username = config.get(CONF_USERNAME, None)
password = config.get(CONF_PASSWORD, None)
Expand Down Expand Up @@ -97,6 +96,8 @@ def unit_of_measurement(self):

def refresh_transmission_data(self):
""" Calls the throttled Transmission refresh method. """
from transmissionrpc.error import TransmissionError

if _THROTTLED_REFRESH is not None:
try:
_THROTTLED_REFRESH()
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/sensor/zwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"""
# pylint: disable=import-error
from homeassistant.helpers.event import track_point_in_time
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher
import datetime
import homeassistant.util.dt as dt_util
import homeassistant.components.zwave as zwave
Expand Down Expand Up @@ -79,6 +77,9 @@ class ZWaveSensor(Entity):
""" Represents a Z-Wave sensor. """

def __init__(self, sensor_value):
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher

self._value = sensor_value
self._node = sensor_value.node

Expand Down
15 changes: 2 additions & 13 deletions homeassistant/components/switch/hikvisioncam.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
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
Expand All @@ -25,20 +19,15 @@

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")
name = config.get('name', "Hikvision Camera Motion Detection")
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,
Expand Down
13 changes: 8 additions & 5 deletions homeassistant/components/switch/orvibo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

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__)
Expand All @@ -20,6 +18,8 @@
# 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
Expand All @@ -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):
Expand All @@ -57,19 +60,19 @@ def update(self):
""" 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")
2 changes: 1 addition & 1 deletion homeassistant/components/switch/rfxtrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""
import logging
import homeassistant.components.rfxtrx as rfxtrx
from RFXtrx import LightingDevice

from homeassistant.components.switch import SwitchDevice
from homeassistant.util import slugify
Expand All @@ -20,6 +19,7 @@

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 = []
Expand Down
19 changes: 10 additions & 9 deletions homeassistant/components/switch/tellstick.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
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']
Expand All @@ -22,11 +20,9 @@
# 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())

Expand Down Expand Up @@ -62,14 +58,17 @@ def unload_telldus_lib(event):

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. """
Expand All @@ -88,6 +87,8 @@ def state_attributes(self):
@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)

Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/switch/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
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__)
Expand All @@ -22,6 +19,9 @@
# 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)
Expand Down
Loading

0 comments on commit 377d2c6

Please sign in to comment.