Add REQUIREMENTS list to components

This commit is contained in:
Paulus Schoutsen 2015-07-07 00:01:46 -07:00
parent aeae7c2c02
commit 940b2998ea
25 changed files with 63 additions and 36 deletions

View file

@ -27,8 +27,10 @@ every initialization the pins are set to off/low.
"""
import logging
from PyMata.pymata import PyMata
import serial
try:
from PyMata.pymata import PyMata
except ImportError:
PyMata = None
from homeassistant.helpers import validate_config
from homeassistant.const import (EVENT_HOMEASSISTANT_START,
@ -36,6 +38,7 @@ from homeassistant.const import (EVENT_HOMEASSISTANT_START,
DOMAIN = "arduino"
DEPENDENCIES = []
REQUIREMENTS = ['PyMata==2.07a']
BOARD = None
_LOGGER = logging.getLogger(__name__)
@ -43,12 +46,18 @@ _LOGGER = logging.getLogger(__name__)
def setup(hass, config):
""" Setup the Arduino component. """
global PyMata # pylint: disable=invalid-name
if PyMata is None:
from PyMata.pymata import PyMata as PyMata_
PyMata = PyMata_
import serial
if not validate_config(config,
{DOMAIN: ['port']},
_LOGGER):
return False
# pylint: disable=global-statement
global BOARD
try:
BOARD = ArduinoBoard(config[DOMAIN]['port'])

View file

@ -22,6 +22,7 @@ from homeassistant.const import (
DOMAIN = "discovery"
DEPENDENCIES = []
REQUIREMENTS = ['zeroconf>=0.16.0']
SCAN_INTERVAL = 300 # seconds

View file

@ -22,6 +22,7 @@ from homeassistant.const import (
# homeassistant constants
DOMAIN = "isy994"
DEPENDENCIES = []
REQUIREMENTS = ['PyISY>=1.0.2']
DISCOVER_LIGHTS = "isy994.lights"
DISCOVER_SWITCHES = "isy994.switches"
DISCOVER_SENSORS = "isy994.sensors"

View file

@ -14,6 +14,7 @@ from homeassistant.const import (
DOMAIN = "keyboard"
DEPENDENCIES = []
REQUIREMENTS = ['pyuserinput>=0.1.9']
def volume_up(hass):

View file

@ -11,6 +11,7 @@ from homeassistant.components.light import (
Light, ATTR_BRIGHTNESS, ATTR_XY_COLOR, ATTR_TRANSITION,
ATTR_FLASH, FLASH_LONG, FLASH_SHORT)
REQUIREMENTS = ['phue>=0.8']
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)

View file

@ -27,15 +27,12 @@ from homeassistant.const import DEVICE_DEFAULT_NAME
from homeassistant.components.light import Light, ATTR_BRIGHTNESS
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['ledcontroller>=1.0.7']
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Gets the LimitlessLED lights. """
try:
import ledcontroller
except ImportError:
_LOGGER.exception("Error while importing dependency ledcontroller.")
return
import ledcontroller
led = ledcontroller.LedController(config['host'])

View file

@ -6,11 +6,8 @@ Provides functionality to interact with Cast devices on the network.
WARNING: This platform is currently not working due to a changed Cast API
"""
import logging
try:
import pychromecast
import pychromecast.controllers.youtube as youtube
except ImportError:
pychromecast = None
@ -25,6 +22,7 @@ from homeassistant.components.media_player import (
SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK,
MEDIA_TYPE_MUSIC, MEDIA_TYPE_TVSHOW, MEDIA_TYPE_VIDEO)
REQUIREMENTS = ['pychromecast>=0.6.8.2']
CAST_SPLASH = 'https://home-assistant.io/images/cast/splash.png'
SUPPORT_CAST = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PREVIOUS_TRACK | \
@ -34,14 +32,10 @@ SUPPORT_CAST = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the cast platform. """
logger = logging.getLogger(__name__)
global pychromecast # pylint: disable=invalid-name
if pychromecast is None:
logger.error((
"Failed to import pychromecast. Did you maybe not install the "
"'pychromecast' dependency?"))
return False
import pychromecast as pychromecast_
pychromecast = pychromecast_
if discovery_info:
hosts = [discovery_info[0]]
@ -67,6 +61,7 @@ class CastDevice(MediaPlayerDevice):
# pylint: disable=too-many-public-methods
def __init__(self, host):
import pychromecast.controllers.youtube as youtube
self.cast = pychromecast.Chromecast(host)
self.youtube = youtube.YouTubeController()
self.cast.register_handler(self.youtube)

View file

@ -49,6 +49,7 @@ except ImportError:
jsonrpc_requests = None
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['jsonrpc-requests>=0.1']
SUPPORT_KODI = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | SUPPORT_SEEK
@ -58,12 +59,10 @@ SUPPORT_KODI = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the kodi platform. """
global jsonrpc_requests # pylint: disable=invalid-name
if jsonrpc_requests is None:
_LOGGER.exception(
"Unable to import jsonrpc_requests. "
"Did you maybe not install the 'jsonrpc-requests' pip module?")
return False
import jsonrpc_requests as jsonrpc_requests_
jsonrpc_requests = jsonrpc_requests_
add_devices([
KodiDevice(

View file

@ -48,7 +48,7 @@ from homeassistant.components.media_player import (
MEDIA_TYPE_MUSIC)
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['python-mpd2>=0.5.4']
SUPPORT_MPD = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_TURN_OFF | \
SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK
@ -62,12 +62,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
port = config.get('port', 6600)
location = config.get('location', 'MPD')
global mpd # pylint: disable=invalid-name
if mpd is None:
_LOGGER.exception(
"Unable to import mpd2. "
"Did you maybe not install the 'python-mpd2' package?")
return False
import mpd as mpd_
mpd = mpd_
# pylint: disable=no-member
try:

View file

@ -28,6 +28,7 @@ from homeassistant.components.notify import (
from homeassistant.const import CONF_API_KEY
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['pushbullet.py>=0.7.1']
def get_service(hass, config):

View file

@ -42,6 +42,7 @@ from homeassistant.components.notify import (
DOMAIN, ATTR_TITLE, BaseNotificationService)
from homeassistant.const import CONF_API_KEY
REQUIREMENTS = ['python-pushover>=0.2']
_LOGGER = logging.getLogger(__name__)

View file

@ -47,6 +47,8 @@ from homeassistant.helpers import validate_config
from homeassistant.components.notify import (
DOMAIN, ATTR_TITLE, BaseNotificationService)
REQUIREMENTS = ['sleekxmpp>=1.3.1']
def get_service(hass, config):
""" Get the Jabber (XMPP) notification service. """

View file

@ -71,6 +71,7 @@ from homeassistant.util import Throttle
from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['blockchain>=1.1.2']
_LOGGER = logging.getLogger(__name__)
OPTION_TYPES = {
'wallet': ['Wallet balance', 'BTC'],

View file

@ -50,7 +50,10 @@ Details for the API : https://developer.forecast.io/docs/v2
import logging
from datetime import timedelta
import forecastio
try:
import forecastio
except ImportError:
forecastio = None
from homeassistant.util import Throttle
from homeassistant.const import (CONF_API_KEY, TEMP_CELCIUS, TEMP_FAHRENHEIT)
@ -79,6 +82,11 @@ MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=120)
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Get the Forecast.io sensor. """
global forecastio # pylint: disable=invalid-name
if forecastio is None:
import forecastio as forecastio_
forecastio = forecastio_
if None in (hass.config.latitude, hass.config.longitude):
_LOGGER.error("Latitude or longitude not set in Home Assistant config")
return False

View file

@ -39,6 +39,7 @@ ATTR_NODE_ID = "node_id"
ATTR_CHILD_ID = "child_id"
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['pyserial>=2.7']
def setup_platform(hass, config, add_devices, discovery_info=None):

View file

@ -48,6 +48,7 @@ from homeassistant.util import Throttle
from homeassistant.const import (CONF_API_KEY, TEMP_CELCIUS, TEMP_FAHRENHEIT)
from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['pywm>=2.2.1']
_LOGGER = logging.getLogger(__name__)
SENSOR_TYPES = {
'weather': ['Condition', ''],

View file

@ -66,6 +66,7 @@ import homeassistant.util.dt as dt_util
from homeassistant.helpers.entity import Entity
from homeassistant.const import STATE_ON, STATE_OFF
REQUIREMENTS = ['psutil>=3.0.0']
SENSOR_TYPES = {
'disk_use_percent': ['Disk Use', '%'],
'disk_use': ['Disk Use', 'GiB'],

View file

@ -67,6 +67,7 @@ from transmissionrpc.error import TransmissionError
import logging
REQUIREMENTS = ['transmissionrpc>=0.11']
SENSOR_TYPES = {
'current_status': ['Status', ''],
'download_speed': ['Down Speed', 'MB/s'],

View file

@ -25,7 +25,7 @@ from datetime import timedelta
try:
import ephem
except ImportError:
# Error will be raised during setup
# Will be fixed during setup
ephem = None
import homeassistant.util.dt as dt_util
@ -33,6 +33,7 @@ from homeassistant.helpers.entity import Entity
from homeassistant.components.scheduler import ServiceEventListener
DEPENDENCIES = []
REQUIREMENTS = ['pyephem>=3.7']
DOMAIN = "sun"
ENTITY_ID = "sun.sun"
@ -100,9 +101,10 @@ def setup(hass, config):
""" Tracks the state of the sun. """
logger = logging.getLogger(__name__)
global ephem # pylint: disable=invalid-name
if ephem is None:
logger.exception("Error while importing dependency ephem.")
return False
import ephem as ephem_
ephem = ephem_
if None in (hass.config.latitude, hass.config.longitude):
logger.error("Latitude or longitude not set in Home Assistant config")

View file

@ -53,7 +53,7 @@ except ImportError:
hikvision.api = None
_LOGGING = logging.getLogger(__name__)
REQUIREMENTS = ['hikvision>=0.4']
# pylint: disable=too-many-arguments
# pylint: disable=too-many-instance-attributes

View file

@ -54,6 +54,7 @@ from transmissionrpc.error import TransmissionError
import logging
_LOGGING = logging.getLogger(__name__)
REQUIREMENTS = ['transmissionrpc>=0.11']
# pylint: disable=unused-argument

View file

@ -6,6 +6,8 @@ import logging
from homeassistant.components.thermostat import ThermostatDevice
from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD, TEMP_CELCIUS)
REQUIREMENTS = ['python-nest>=2.3.1']
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):

View file

@ -13,6 +13,7 @@ from homeassistant.const import (
DOMAIN = "zwave"
DEPENDENCIES = []
REQUIREMENTS = ['pydispatcher>=2.0.5']
CONF_USB_STICK_PATH = "usb_path"
DEFAULT_CONF_USB_STICK_PATH = "/zwaveusbstick"

View file

@ -9,13 +9,15 @@ reports=no
# abstract-class-little-used - Prevents from setting right foundation
# abstract-class-not-used - is flaky, should not show up but does
# unused-argument - generic callbacks and setup methods create a lot of warnings
# global-statement - used for the on-demand requirement installation
disable=
locally-disabled,
duplicate-code,
cyclic-import,
abstract-class-little-used,
abstract-class-not-used,
unused-argument
unused-argument,
global-statement
[EXCEPTIONS]
overgeneral-exceptions=Exception,HomeAssistantError

View file

@ -68,7 +68,7 @@ hikvision>=0.4
# console log coloring
colorlog>=2.6.0
# JSON-RPC interface
# JSON-RPC interface (media_player.kodi)
jsonrpc-requests>=0.1
# Forecast.io Bindings (sensor.forecast)