Exemplo n.º 1
0
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Set up a MQTT Template light."""
    if discovery_info is not None:
        config = PLATFORM_SCHEMA(discovery_info)

    async_add_devices([MqttTemplate(
        hass,
        config.get(CONF_NAME),
        config.get(CONF_EFFECT_LIST),
        {
            key: config.get(key) for key in (
                CONF_STATE_TOPIC,
                CONF_COMMAND_TOPIC
            )
        },
        {
            key: config.get(key) for key in (
                CONF_BLUE_TEMPLATE,
                CONF_BRIGHTNESS_TEMPLATE,
                CONF_COLOR_TEMP_TEMPLATE,
                CONF_COMMAND_OFF_TEMPLATE,
                CONF_COMMAND_ON_TEMPLATE,
                CONF_EFFECT_TEMPLATE,
                CONF_GREEN_TEMPLATE,
                CONF_RED_TEMPLATE,
                CONF_STATE_TEMPLATE,
                CONF_WHITE_VALUE_TEMPLATE,
            )
        },
        config.get(CONF_OPTIMISTIC),
        config.get(CONF_QOS),
        config.get(CONF_RETAIN)
    )])
Exemplo n.º 2
0
REQUIREMENTS = ['pykonkeio>=2.1.7']

_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = "Konke Light"

CONF_MODEL = 'model'
MODEL_KLIGHT = 'klight'
MODEL_KBULB = 'kbulb'
MODEL_K2_LIGHT = 'k2_light'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Required(CONF_MODEL):
    vol.In((MODEL_KLIGHT, MODEL_KBULB, MODEL_K2_LIGHT)),
})

KBLUB_MIN_KELVIN = 2700
KBLUB_MAX_KELVIN = 6493


async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up Konke light platform."""
    name = config[CONF_NAME]
    host = config[CONF_HOST]
Exemplo n.º 3
0
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Set up a MQTT JSON Light."""
    if discovery_info is not None:
        config = PLATFORM_SCHEMA(discovery_info)
    async_add_devices([MqttJson(
        config.get(CONF_NAME),
        config.get(CONF_EFFECT_LIST),
        {
            key: config.get(key) for key in (
                CONF_STATE_TOPIC,
                CONF_COMMAND_TOPIC
            )
        },
        config.get(CONF_QOS),
        config.get(CONF_RETAIN),
        config.get(CONF_OPTIMISTIC),
        config.get(CONF_BRIGHTNESS),
        config.get(CONF_COLOR_TEMP),
        config.get(CONF_EFFECT),
        config.get(CONF_RGB),
        config.get(CONF_WHITE_VALUE),
        config.get(CONF_XY),
        {
            key: config.get(key) for key in (
                CONF_FLASH_TIME_SHORT,
                CONF_FLASH_TIME_LONG
            )
        }
    )])
Exemplo n.º 4
0
# Delay (in ms) expected for changes to take effect in the physical bulb
BULB_LATENCY = 500

CONF_SERVER = 'server'

ATTR_HSBK = 'hsbk'

BYTE_MAX = 255
SHORT_MAX = 65535

SUPPORT_LIFX = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR |
                SUPPORT_XY_COLOR | SUPPORT_TRANSITION | SUPPORT_EFFECT)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_SERVER, default='0.0.0.0'): cv.string,
})


@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Set up the LIFX platform."""
    import aiolifx

    if sys.platform == 'win32':
        _LOGGER.warning("The lifx platform is known to not work on Windows. "
                        "Consider using the lifx_legacy platform instead")

    server_addr = config.get(CONF_SERVER)

    lifx_manager = LIFXManager(hass, async_add_devices)
Exemplo n.º 5
0
from homeassistant.const import CONF_NAME
from homeassistant.components.rfxtrx import (
    CONF_AUTOMATIC_ADD, CONF_FIRE_EVENT, DEFAULT_SIGNAL_REPETITIONS,
    CONF_SIGNAL_REPETITIONS, CONF_DEVICES)
from homeassistant.helpers import config_validation as cv

DEPENDENCIES = ['rfxtrx']

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_DEVICES, default={}): {
        cv.string: vol.Schema({
            vol.Required(CONF_NAME): cv.string,
            vol.Optional(CONF_FIRE_EVENT, default=False): cv.boolean
        })
    },
    vol.Optional(CONF_AUTOMATIC_ADD, default=False):  cv.boolean,
    vol.Optional(CONF_SIGNAL_REPETITIONS, default=DEFAULT_SIGNAL_REPETITIONS):
        vol.Coerce(int),
})

SUPPORT_RFXTRX = SUPPORT_BRIGHTNESS


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the RFXtrx platform."""
    import RFXtrx as rfxtrxmod

    lights = rfxtrx.get_devices_from_config(config, RfxtrxLight)
    add_entities(lights)
Exemplo n.º 6
0
}

FLUX_EFFECT_LIST = [
    EFFECT_RANDOM,
    ] + list(EFFECT_MAP)

DEVICE_SCHEMA = vol.Schema({
    vol.Optional(CONF_NAME): cv.string,
    vol.Optional(ATTR_MODE, default=MODE_RGBW):
        vol.All(cv.string, vol.In([MODE_RGBW, MODE_RGB, MODE_WHITE])),
    vol.Optional(CONF_PROTOCOL):
        vol.All(cv.string, vol.In(['ledenet'])),
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA},
    vol.Optional(CONF_AUTOMATIC_ADD, default=False):  cv.boolean,
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the Flux lights."""
    import flux_led
    lights = []
    light_ips = []

    for ipaddr, device_config in config.get(CONF_DEVICES, {}).items():
        device = {}
        device['name'] = device_config[CONF_NAME]
        device['ipaddr'] = ipaddr
        device[CONF_PROTOCOL] = device_config.get(CONF_PROTOCOL)
        device[ATTR_MODE] = device_config[ATTR_MODE]
Exemplo n.º 7
0
ATTR_EMULATED_HUE_HIDDEN = 'emulated_hue_hidden'
ATTR_IS_HUE_GROUP = 'is_hue_group'

# Legacy configuration, will be removed in 0.60
CONF_ALLOW_UNREACHABLE = 'allow_unreachable'
DEFAULT_ALLOW_UNREACHABLE = False
CONF_ALLOW_IN_EMULATED_HUE = 'allow_in_emulated_hue'
DEFAULT_ALLOW_IN_EMULATED_HUE = True
CONF_ALLOW_HUE_GROUPS = 'allow_hue_groups'
DEFAULT_ALLOW_HUE_GROUPS = True

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_HOST): cv.string,
    vol.Optional(CONF_ALLOW_UNREACHABLE): cv.boolean,
    vol.Optional(CONF_FILENAME): cv.string,
    vol.Optional(CONF_ALLOW_IN_EMULATED_HUE): cv.boolean,
    vol.Optional(CONF_ALLOW_HUE_GROUPS,
                 default=DEFAULT_ALLOW_HUE_GROUPS): cv.boolean,
})

MIGRATION_ID = 'light_hue_config_migration'
MIGRATION_TITLE = 'Philips Hue Configuration Migration'
MIGRATION_INSTRUCTIONS = """
Configuration for the Philips Hue component has changed; action required.

You have configured at least one bridge:

    hue:
{config}

This configuration is deprecated, please check the
Exemplo n.º 8
0
_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = 'Xiaomi Philips Light'
DATA_KEY = 'light.xiaomi_miio'

CONF_MODEL = 'model'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_TOKEN): vol.All(cv.string, vol.Length(min=32, max=32)),
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_MODEL): vol.In(
        ['philips.light.sread1',
         'philips.light.ceiling',
         'philips.light.zyceiling',
         'philips.light.moonlight',
         'philips.light.bulb',
         'philips.light.candle',
         'philips.light.candle2',
         'philips.light.mono1',
         'philips.light.downlight',
         ]),
})

# The light does not accept cct values < 1
CCT_MIN = 1
CCT_MAX = 100

DELAYED_TURN_OFF_MAX_DEVIATION_SECONDS = 4
DELAYED_TURN_OFF_MAX_DEVIATION_MINUTES = 1
Exemplo n.º 9
0
REQUIREMENTS = ['aiolifx==0.5.4', 'aiolifx_effects==0.1.1']

UDP_BROADCAST_PORT = 56700

DISCOVERY_INTERVAL = 60
MESSAGE_TIMEOUT = 1.0
MESSAGE_RETRIES = 8
UNAVAILABLE_GRACE = 90

CONF_SERVER = 'server'
CONF_BROADCAST = 'broadcast'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_SERVER, default='0.0.0.0'):
    cv.string,
    vol.Optional(CONF_BROADCAST, default='255.255.255.255'):
    cv.string,
})

SERVICE_LIFX_SET_STATE = 'lifx_set_state'

ATTR_INFRARED = 'infrared'
ATTR_ZONES = 'zones'
ATTR_POWER = 'power'

LIFX_SET_STATE_SCHEMA = LIGHT_TURN_ON_SCHEMA.extend({
    ATTR_INFRARED:
    vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255)),
    ATTR_ZONES:
    vol.All(cv.ensure_list, [cv.positive_int]),
    ATTR_POWER:
Exemplo n.º 10
0
]

_LOGGER = logging.getLogger(__name__)

# Validation of the user's configuration
# Host should be MAC Address
CONF_DEVICES = 'devices'
CONF_VERSION = 'version'

DEFAULT_VERSION = 10

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_DEVICES):
    vol.All(cv.ensure_list, [
        {
            vol.Required(CONF_HOST): cv.string,
            vol.Optional(CONF_VERSION, default=DEFAULT_VERSION):
            cv.positive_int,
        },
    ]),
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Magic Blue platform."""

    from magicbluelib import magicblue

    # Assign configuration variables. The configuration check takes care they are
    # present.
    host = config.get(CONF_HOST)
    version = config.get(CONF_VERSION)
Exemplo n.º 11
0
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Optional(CONF_UNIVERSE, default=0):
    cv.byte,
    vol.Optional(CONF_DMX_CHANNELS, default=512):
    vol.All(vol.Coerce(int), vol.Range(min=1, max=512)),
    vol.Optional(CONF_DEFAULT_LEVEL, default=255):
    cv.byte,
    vol.Optional(CONF_DEFAULT_TYPE, default=CONF_LIGHT_TYPE_DIMMER):
    cv.string,
    vol.Required(CONF_DEVICES):
    vol.All(cv.ensure_list, [{
        vol.Required(CONF_CHANNEL):
        vol.All(vol.Coerce(int), vol.Range(min=1, max=512)),
        vol.Optional(CONF_NAME):
        cv.string,
        vol.Optional(CONF_TYPE):
        vol.In(CONF_LIGHT_TYPES),
        vol.Optional(CONF_DEFAULT_LEVEL):
        cv.byte,
        vol.Optional(ATTR_WHITE_VALUE):
        cv.byte,
        vol.Optional(CONF_DEFAULT_COLOR):
        vol.All(vol.ExactSequence(
            (cv.byte, cv.byte, cv.byte)), vol.Coerce(tuple)),
        vol.Optional(CONF_TRANSITION, default=0):
        vol.All(vol.Coerce(int), vol.Range(min=0, max=60)),
        vol.Optional(CONF_CHANNEL_SETUP):
        cv.string,
    }]),
    vol.Optional(CONF_PORT, default=6454):
    cv.port,
    vol.Optional(CONF_SEND_LEVELS_ON_STARTUP, default=True):
    cv.boolean,
})
Exemplo n.º 12
0
from homeassistant.components import enocean
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

CONF_SENDER_ID = 'sender_id'

DEFAULT_NAME = 'EnOcean Light'
DEPENDENCIES = ['enocean']

SUPPORT_ENOCEAN = SUPPORT_BRIGHTNESS

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_ID, default=[]):
    vol.All(cv.ensure_list, [vol.Coerce(int)]),
    vol.Required(CONF_SENDER_ID):
    vol.All(cv.ensure_list, [vol.Coerce(int)]),
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the EnOcean light platform."""
    sender_id = config.get(CONF_SENDER_ID)
    devname = config.get(CONF_NAME)
    dev_id = config.get(CONF_ID)

    add_devices([EnOceanLight(sender_id, devname, dev_id)])


class EnOceanLight(enocean.EnOceanDevice, Light):
Exemplo n.º 13
0
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_ADDRESS):
    cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Optional(CONF_STATE_ADDRESS):
    cv.string,
    vol.Optional(CONF_BRIGHTNESS_ADDRESS):
    cv.string,
    vol.Optional(CONF_BRIGHTNESS_STATE_ADDRESS):
    cv.string,
    vol.Optional(CONF_COLOR_ADDRESS):
    cv.string,
    vol.Optional(CONF_COLOR_STATE_ADDRESS):
    cv.string,
    vol.Optional(CONF_COLOR_TEMP_ADDRESS):
    cv.string,
    vol.Optional(CONF_COLOR_TEMP_STATE_ADDRESS):
    cv.string,
    vol.Optional(CONF_COLOR_TEMP_MODE, default=DEFAULT_COLOR_TEMP_MODE):
    cv.enum(ColorTempModes),
    vol.Optional(CONF_RGBW_ADDRESS):
    cv.string,
    vol.Optional(CONF_RGBW_STATE_ADDRESS):
    cv.string,
    vol.Optional(CONF_MIN_KELVIN, default=DEFAULT_MIN_KELVIN):
    vol.All(vol.Coerce(int), vol.Range(min=1)),
    vol.Optional(CONF_MAX_KELVIN, default=DEFAULT_MAX_KELVIN):
    vol.All(vol.Coerce(int), vol.Range(min=1)),
})
Exemplo n.º 14
0
DOMAIN = "light"
SERVICE_HUE_SCENE = "hue_activate_scene"

MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)

PHUE_CONFIG_FILE = 'phue.conf'

SUPPORT_HUE = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_EFFECT
               | SUPPORT_FLASH | SUPPORT_RGB_COLOR | SUPPORT_TRANSITION
               | SUPPORT_XY_COLOR)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Optional(CONF_ALLOW_UNREACHABLE):
    cv.boolean,
    vol.Optional(CONF_FILENAME):
    cv.string,
})

ATTR_GROUP_NAME = "group_name"
ATTR_SCENE_NAME = "scene_name"
SCENE_SCHEMA = vol.Schema({
    vol.Required(ATTR_GROUP_NAME): cv.string,
    vol.Required(ATTR_SCENE_NAME): cv.string,
})


def _find_host_from_config(hass, filename=PHUE_CONFIG_FILE):
    """Attempt to detect host based on existing configuration."""
    path = hass.config.path(filename)
Exemplo n.º 15
0
Arquivo: light.py Projeto: jbouwh/core
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Optional(CONF_DEVICE_DEFAULTS, default=DEVICE_DEFAULTS_SCHEMA({})):
        DEVICE_DEFAULTS_SCHEMA,
        vol.Optional(CONF_AUTOMATIC_ADD, default=True): cv.boolean,
        vol.Optional(CONF_DEVICES, default={}): {
            cv.string:
            vol.Schema({
                vol.Optional(CONF_NAME):
                cv.string,
                vol.Optional(CONF_TYPE):
                vol.Any(TYPE_DIMMABLE, TYPE_SWITCHABLE, TYPE_HYBRID,
                        TYPE_TOGGLE),
                vol.Optional(CONF_ALIASES, default=[]):
                vol.All(cv.ensure_list, [cv.string]),
                vol.Optional(CONF_GROUP_ALIASES, default=[]):
                vol.All(cv.ensure_list, [cv.string]),
                vol.Optional(CONF_NOGROUP_ALIASES, default=[]):
                vol.All(cv.ensure_list, [cv.string]),
                vol.Optional(CONF_FIRE_EVENT):
                cv.boolean,
                vol.Optional(CONF_SIGNAL_REPETITIONS):
                vol.Coerce(int),
                vol.Optional(CONF_GROUP, default=True):
                cv.boolean,
            })
        },
    },
    extra=vol.ALLOW_EXTRA,
)
Exemplo n.º 16
0
import logging
import voluptuous as vol
from homeassistant.components.light import Light, ATTR_BRIGHTNESS, \
    SUPPORT_BRIGHTNESS, PLATFORM_SCHEMA
from homeassistant.const import CONF_NAME
from homeassistant.components.ads import DATA_ADS, CONF_ADS_VAR, \
    CONF_ADS_VAR_BRIGHTNESS
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['ads']
DEFAULT_NAME = 'ADS Light'
CONF_ADSVAR_BRIGHTNESS = 'adsvar_brightness'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_ADS_VAR): cv.string,
    vol.Optional(CONF_ADS_VAR_BRIGHTNESS): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the light platform for ADS."""
    ads_hub = hass.data.get(DATA_ADS)

    ads_var_enable = config.get(CONF_ADS_VAR)
    ads_var_brightness = config.get(CONF_ADS_VAR_BRIGHTNESS)
    name = config.get(CONF_NAME)

    add_entities([AdsLight(ads_hub, ads_var_enable, ads_var_brightness,
                           name)], True)
Exemplo n.º 17
0
from homeassistant.components.light import (
    ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light, PLATFORM_SCHEMA)
from homeassistant.components import mochad
from homeassistant.const import (CONF_NAME, CONF_PLATFORM, CONF_DEVICES,
                                 CONF_ADDRESS)
from homeassistant.helpers import config_validation as cv

DEPENDENCIES = ['mochad']
_LOGGER = logging.getLogger(__name__)


PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_PLATFORM): mochad.DOMAIN,
    CONF_DEVICES: [{
        vol.Optional(CONF_NAME): cv.string,
        vol.Required(CONF_ADDRESS): cv.x10_address,
        vol.Optional(mochad.CONF_COMM_TYPE): cv.string,
    }]
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up X10 dimmers over a mochad controller."""
    devs = config.get(CONF_DEVICES)
    add_devices([MochadLight(
        hass, mochad.CONTROLLER.ctrl, dev) for dev in devs])
    return True


class MochadLight(Light):
    """Representation of a X10 dimmer over Mochad."""
Exemplo n.º 18
0
                              | SUPPORT_TRANSITION)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_BRIDGES):
    vol.All(
        cv.ensure_list,
        [{
            vol.Required(CONF_HOST):
            cv.string,
            vol.Optional(CONF_VERSION, default=DEFAULT_VERSION):
            cv.positive_int,
            vol.Optional(CONF_PORT, default=DEFAULT_PORT):
            cv.port,
            vol.Required(CONF_GROUPS):
            vol.All(
                cv.ensure_list,
                [{
                    vol.Required(CONF_NAME):
                    cv.string,
                    vol.Optional(CONF_TYPE, default=DEFAULT_LED_TYPE):
                    vol.In(LED_TYPE),
                    vol.Required(CONF_NUMBER):
                    cv.positive_int,
                    vol.Optional(CONF_FADE, default=DEFAULT_FADE):
                    cv.boolean,
                }],
            ),
        }],
    )
})

Exemplo n.º 19
0
import voluptuous as vol

from homeassistant.components.light import (
    ATTR_BRIGHTNESS, ATTR_TRANSITION, Light,
    PLATFORM_SCHEMA, SUPPORT_BRIGHTNESS, SUPPORT_TRANSITION)
from homeassistant.const import (
    CONF_USERNAME, CONF_PASSWORD,
    EVENT_HOMEASSISTANT_STOP)
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

# Validation of the user's configuration
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
})

NOTIFICATION_ID = 'leviton_notification'
NOTIFICATION_TITLE = 'myLeviton Decora Setup'


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Decora WiFi platform."""
    # pylint: disable=import-error, no-name-in-module
    from decora_wifi import DecoraWiFiSession
    from decora_wifi.models.person import Person
    from decora_wifi.models.residential_account import ResidentialAccount
    from decora_wifi.models.residence import Residence

    email = config.get(CONF_USERNAME)
Exemplo n.º 20
0
CONF_BROADCAST = 'broadcast'
CONF_SERVER = 'server'

SHORT_MAX = 65535

TEMP_MAX = 9000
TEMP_MAX_HASS = 500
TEMP_MIN = 2500
TEMP_MIN_HASS = 154

SUPPORT_LIFX = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR
                | SUPPORT_TRANSITION)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_SERVER, default=None):
    cv.string,
    vol.Optional(CONF_BROADCAST, default=None):
    cv.string,
})


# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the LIFX platform."""
    server_addr = config.get(CONF_SERVER)
    broadcast_addr = config.get(CONF_BROADCAST)

    lifx_library = LIFX(add_devices, server_addr, broadcast_addr)

    # Register our poll service
    track_time_change(hass, lifx_library.poll, second=[10, 40])
Exemplo n.º 21
0
import voluptuous as vol

# Home assistant stuff - use class from above to setup light access
from homeassistant.components.light import (
    ATTR_RGB_COLOR, ATTR_HS_COLOR, SUPPORT_COLOR, Light, PLATFORM_SCHEMA)
from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv
import homeassistant.util.color as color_util

_LOGGER = logging.getLogger(__name__)

SUPPORT_PILIGHT = (SUPPORT_COLOR)

# Configuration
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_NAME, default='PiDioder'): cv.string
})

# HA hook
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
    # Just add one default PiDioder light with default address
    add_devices_callback([PiDioderLight(0x40, _LOGGER, config.get(CONF_NAME))])

# Representation of a polling-type light for HA, using the PiDioder class
class PiDioderLight(Light):

    def __init__(self, addr, log, name):
        # initialize PiDioder light at I2C address and put to sleep
        self._dev = PiDioder(addr, log)
        self._dev.set_freq(1000)
        self._is_sleep = True
Exemplo n.º 22
0
    SUPPORT_WHITE_VALUE,
    LightEntity,
)

# Home Assistant depends on 3rd party packages for API specific code.
# REQUIREMENTS = ['awesome_lights==1.2.3']

# custom_components.light.barneyman to enable in config.yaml
_LOGGER = logging.getLogger(__name__)

DOMAIN = "barneyman"

CONF_DEVICES = "devices"

# Validation of the user's configuration
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {vol.Optional(CONF_DEVICES): cv.ensure_list})

from homeassistant.helpers import discovery


# this gets called if you're a platform under a component
def setup_platform(hass, config, add_devices, discovery_info=None):

    devices = []

    if discovery_info != None:
        configToUse = discovery_info

        _LOGGER.debug("Setting up barneyman via discovery ... %s", configToUse)

        devices = [configToUse["host"]]
Exemplo n.º 23
0
_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = 'Nanoleaf'

DATA_NANOLEAF = 'nanoleaf'

CONFIG_FILE = '.nanoleaf.conf'

ICON = 'mdi:triangle-outline'

SUPPORT_NANOLEAF = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_EFFECT |
                    SUPPORT_COLOR)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_TOKEN): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Nanoleaf light."""
    from pynanoleaf import Nanoleaf, Unavailable
    if DATA_NANOLEAF not in hass.data:
        hass.data[DATA_NANOLEAF] = dict()

    token = ''
    if discovery_info is not None:
        host = discovery_info['host']
        name = discovery_info['hostname']
        # if device already exists via config, skip discovery setup
Exemplo n.º 24
0
import logging
import re
import pexpect
import voluptuous as vol
import homeassistant.helpers.config_validation as cv

from datetime import timedelta
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from homeassistant.components.light import PLATFORM_SCHEMA, LightEntity

_LOGGER = logging.getLogger(__name__)

SCAN_INTERVAL = timedelta(seconds=10)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {vol.Required('devices'): vol.All(cv.ensure_list, [cv.string])})


def le_scan(devices, timeout=5):
    found_devices = []

    try:
        scan = pexpect.spawn('hcitool lescan --discovery=l',
                             ignore_sighup=False)
        scan.expect('nonsense value foobar', timeout=timeout)
    except (pexpect.EOF, pexpect.TIMEOUT):
        for line in scan.before.splitlines():
            match = re.match(r'(([0-9A-Fa-f]{2}:?){6}) (\(?.+\)?)',
                             line.decode())
            if match is not None:
                address = match.group(1)
Exemplo n.º 25
0
CONF_BRIGHTNESS_TEMPLATE = 'brightness_template'
CONF_RED_TEMPLATE = 'red_template'
CONF_GREEN_TEMPLATE = 'green_template'
CONF_BLUE_TEMPLATE = 'blue_template'

SUPPORT_MQTT_TEMPLATE = (SUPPORT_BRIGHTNESS | SUPPORT_FLASH |
                         SUPPORT_RGB_COLOR | SUPPORT_TRANSITION)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Required(CONF_COMMAND_TOPIC): mqtt.valid_publish_topic,
    vol.Optional(CONF_STATE_TOPIC): mqtt.valid_subscribe_topic,
    vol.Required(CONF_COMMAND_ON_TEMPLATE): cv.template,
    vol.Required(CONF_COMMAND_OFF_TEMPLATE): cv.template,
    vol.Optional(CONF_STATE_TEMPLATE): cv.template,
    vol.Optional(CONF_BRIGHTNESS_TEMPLATE): cv.template,
    vol.Optional(CONF_RED_TEMPLATE): cv.template,
    vol.Optional(CONF_GREEN_TEMPLATE): cv.template,
    vol.Optional(CONF_BLUE_TEMPLATE): cv.template,
    vol.Optional(CONF_OPTIMISTIC, default=DEFAULT_OPTIMISTIC): cv.boolean,
    vol.Optional(CONF_QOS, default=mqtt.DEFAULT_QOS):
        vol.All(vol.Coerce(int), vol.In([0, 1, 2])),
    vol.Optional(CONF_RETAIN, default=mqtt.DEFAULT_RETAIN): cv.boolean
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup a MQTT Template light."""
    add_devices([MqttTemplate(
        hass,
        config.get(CONF_NAME),
        {
Exemplo n.º 26
0
from homeassistant.core import CALLBACK_TYPE, State, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_state_change
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.util import color as color_util

# mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs
# mypy: no-check-untyped-defs

_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = "Light Group"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Required(CONF_ENTITIES):
    cv.entities_domain(light.DOMAIN),
})

SUPPORT_GROUP_LIGHT = (SUPPORT_BRIGHTNESS
                       | SUPPORT_COLOR_TEMP
                       | SUPPORT_EFFECT
                       | SUPPORT_FLASH
                       | SUPPORT_COLOR
                       | SUPPORT_TRANSITION
                       | SUPPORT_WHITE_VALUE)


async def async_setup_platform(hass: HomeAssistantType,
                               config: ConfigType,
                               async_add_entities,
Exemplo n.º 27
0
import homeassistant.helpers.config_validation as cv
from homeassistant.components.light import (
    ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, ATTR_RGB_COLOR, SUPPORT_RGB_COLOR,
    Light, PLATFORM_SCHEMA)
from homeassistant.const import CONF_NAME

REQUIREMENTS = ['piglow==1.2.4']

_LOGGER = logging.getLogger(__name__)

SUPPORT_PIGLOW = (SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR)

DEFAULT_NAME = 'Piglow'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the Piglow Light platform."""
    import piglow

    if subprocess.getoutput("i2cdetect  -q -y 1 | grep -o 54") != '54':
        _LOGGER.error("A Piglow device was not found")
        return False

    name = config.get(CONF_NAME)

    add_devices([PiglowLight(piglow, name)])
Exemplo n.º 28
0
from homeassistant.components.knx import (KNXConfig, KNXGroupAddress)
from homeassistant.components.light import (Light, PLATFORM_SCHEMA)
from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv

CONF_ADDRESS = 'address'
CONF_STATE_ADDRESS = 'state_address'

DEFAULT_NAME = 'KNX Light'
DEPENDENCIES = ['knx']

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_ADDRESS):
    cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Optional(CONF_STATE_ADDRESS):
    cv.string,
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the KNX light platform."""
    add_devices([KNXLight(hass, KNXConfig(config))])


class KNXLight(KNXGroupAddress, Light):
    """Representation of a KNX Light device."""
    def turn_on(self, **kwargs):
        """Turn the switch on.
Exemplo n.º 29
0
_LOGGER = logging.getLogger(__name__)

ATTR_STATION_ID = 'station_id'
ATTR_STATION_NAME = 'station_name'

CONF_STATION_ID = 'station_id'
CONF_FUEL_TYPES = 'fuel_types'
CONF_ALLOWED_FUEL_TYPES = ["E10", "U91", "E85", "P95", "P98", "DL",
                           "PDL", "B20", "LPG", "CNG", "EV"]
CONF_DEFAULT_FUEL_TYPES = ["E10", "U91"]

ATTRIBUTION = "Data provided by NSW Government FuelCheck"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_STATION_ID): cv.positive_int,
    vol.Optional(CONF_FUEL_TYPES, default=CONF_DEFAULT_FUEL_TYPES):
        vol.All(cv.ensure_list, [vol.In(CONF_ALLOWED_FUEL_TYPES)]),
})

MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(hours=1)

NOTIFICATION_ID = 'nsw_fuel_station_notification'
NOTIFICATION_TITLE = 'NSW Fuel Station Sensor Setup'


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the NSW Fuel Station sensor."""
    from nsw_fuel import FuelCheckClient

    station_id = config[CONF_STATION_ID]
    fuel_types = config[CONF_FUEL_TYPES]
Exemplo n.º 30
0
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Optional(CONF_EFFECT_LIST):
    vol.All(cv.ensure_list, [cv.string]),
    vol.Required(CONF_COMMAND_TOPIC):
    mqtt.valid_publish_topic,
    vol.Optional(CONF_STATE_TOPIC):
    mqtt.valid_subscribe_topic,
    vol.Required(CONF_COMMAND_ON_TEMPLATE):
    cv.template,
    vol.Required(CONF_COMMAND_OFF_TEMPLATE):
    cv.template,
    vol.Optional(CONF_STATE_TEMPLATE):
    cv.template,
    vol.Optional(CONF_BRIGHTNESS_TEMPLATE):
    cv.template,
    vol.Optional(CONF_RED_TEMPLATE):
    cv.template,
    vol.Optional(CONF_GREEN_TEMPLATE):
    cv.template,
    vol.Optional(CONF_BLUE_TEMPLATE):
    cv.template,
    vol.Optional(CONF_EFFECT_TEMPLATE):
    cv.template,
    vol.Optional(CONF_OPTIMISTIC, default=DEFAULT_OPTIMISTIC):
    cv.boolean,
    vol.Optional(CONF_QOS, default=mqtt.DEFAULT_QOS):
    vol.All(vol.Coerce(int), vol.In([0, 1, 2])),
    vol.Optional(CONF_RETAIN, default=mqtt.DEFAULT_RETAIN):
    cv.boolean
})
Exemplo n.º 31
0
SUPPORT_LIMITLESSLED_RGB = (SUPPORT_BRIGHTNESS | SUPPORT_EFFECT |
                            SUPPORT_FLASH | SUPPORT_RGB_COLOR |
                            SUPPORT_TRANSITION)
SUPPORT_LIMITLESSLED_RGBWW = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP |
                              SUPPORT_EFFECT | SUPPORT_FLASH |
                              SUPPORT_RGB_COLOR | SUPPORT_TRANSITION)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_BRIDGES): vol.All(cv.ensure_list, [
        {
            vol.Required(CONF_HOST): cv.string,
            vol.Optional(CONF_VERSION,
                         default=DEFAULT_VERSION): cv.positive_int,
            vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
            vol.Required(CONF_GROUPS):  vol.All(cv.ensure_list, [
                {
                    vol.Required(CONF_NAME): cv.string,
                    vol.Optional(CONF_TYPE, default=DEFAULT_LED_TYPE):
                        vol.In(LED_TYPE),
                    vol.Required(CONF_NUMBER): cv.positive_int,
                }
            ]),
        },
    ]),
})


def rewrite_legacy(config):
    """Rewrite legacy configuration to new format."""
    bridges = config.get(CONF_BRIDGES, [config])
    new_bridges = []
    for bridge_conf in bridges:
Exemplo n.º 32
0
CONF_LED_TYPE_RGB = 'rgb'
CONF_LED_TYPE_RGBW = 'rgbw'
CONF_LED_TYPES = [CONF_LED_TYPE_SIMPLE, CONF_LED_TYPE_RGB, CONF_LED_TYPE_RGBW]

DEFAULT_COLOR = [255, 255, 255]

SUPPORT_SIMPLE_LED = (SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION)
SUPPORT_RGB_LED = (SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR | SUPPORT_TRANSITION)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_LEDS):
    vol.All(
        cv.ensure_list,
        [{
            vol.Required(CONF_NAME): cv.string,
            vol.Required(CONF_DRIVER): vol.In(CONF_DRIVER_TYPES),
            vol.Required(CONF_PINS): vol.All(cv.ensure_list,
                                             [cv.positive_int]),
            vol.Required(CONF_TYPE): vol.In(CONF_LED_TYPES),
            vol.Optional(CONF_FREQUENCY): cv.positive_int,
            vol.Optional(CONF_ADDRESS): cv.byte
        }])
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the pwm lights."""
    from pwmled.led import SimpleLed
    from pwmled.led.rgb import RgbLed
    from pwmled.led.rgbw import RgbwLed
    from pwmled.driver.gpio import GpioDriver
    from pwmled.driver.pca9685 import Pca9685Driver
Exemplo n.º 33
0
                                            ATTR_RGB_COLOR, SUPPORT_RGB_COLOR,
                                            ATTR_BRIGHTNESS,
                                            SUPPORT_BRIGHTNESS,
                                            PLATFORM_SCHEMA)
from homeassistant.const import CONF_HOST
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['yeelightsunflower==0.0.8']

_LOGGER = logging.getLogger(__name__)


SUPPORT_YEELIGHT_SUNFLOWER = (SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the Yeelight Sunflower Light platform."""
    import yeelightsunflower

    host = config.get(CONF_HOST)
    hub = yeelightsunflower.Hub(host)

    if not hub.available:
        _LOGGER.error('Could not connect to Yeelight Sunflower hub')
        return False

    add_devices(SunflowerBulb(light) for light in hub.get_lights())
Exemplo n.º 34
0
)
from homeassistant.core import CALLBACK_TYPE, State, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_state_change
from homeassistant.helpers.typing import ConfigType, HomeAssistantType

# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs

_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = "Light Switch"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Required(CONF_ENTITY_ID):
    cv.entity_domain(switch.DOMAIN),
})


async def async_setup_platform(
    hass: HomeAssistantType,
    config: ConfigType,
    async_add_entities: Callable[[Sequence[Entity], bool], None],
    discovery_info: Optional[Dict] = None,
) -> None:
    """Initialize Light Switch platform."""
    async_add_entities([
        LightSwitch(cast(str, config.get(CONF_NAME)), config[CONF_ENTITY_ID])
    ], True)
Exemplo n.º 35
0
from homeassistant.components import switch
from homeassistant.const import (
    ATTR_ENTITY_ID, CONF_ENTITY_ID, CONF_NAME, STATE_ON, STATE_UNAVAILABLE)
from homeassistant.core import State, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_state_change
from homeassistant.helpers.typing import ConfigType, HomeAssistantType

from homeassistant.components.light import PLATFORM_SCHEMA, Light

_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = 'Light Switch'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Required(CONF_ENTITY_ID): cv.entity_domain(switch.DOMAIN)
})


async def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
                               async_add_entities,
                               discovery_info=None) -> None:
    """Initialize Light Switch platform."""
    async_add_entities([LightSwitch(config.get(CONF_NAME),
                                    config[CONF_ENTITY_ID])], True)


class LightSwitch(Light):
    """Represents a Switch as a Light."""

    def __init__(self, name: str, switch_entity_id: str) -> None:
Exemplo n.º 36
0
    PLATFORM_SCHEMA,
    SUPPORT_BRIGHTNESS,
    SUPPORT_COLOR,
    LightEntity,
)
from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv
import homeassistant.util.color as color_util

_LOGGER = logging.getLogger(__name__)

SUPPORT_BLINKT = SUPPORT_BRIGHTNESS | SUPPORT_COLOR

DEFAULT_NAME = "blinkt"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Blinkt Light platform."""
    # pylint: disable=no-member
    blinkt = importlib.import_module("blinkt")

    # ensure that the lights are off when exiting
    blinkt.set_clear_on_exit()

    name = config[CONF_NAME]

    add_entities([
        BlinktLight(blinkt, name, index) for index in range(blinkt.NUM_PIXELS)
    ])
Exemplo n.º 37
0
CONF_EFFECT_TEMPLATE = 'effect_template'
CONF_GREEN_TEMPLATE = 'green_template'
CONF_RED_TEMPLATE = 'red_template'
CONF_STATE_TEMPLATE = 'state_template'
CONF_WHITE_VALUE_TEMPLATE = 'white_value_template'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_BLUE_TEMPLATE): cv.template,
    vol.Optional(CONF_BRIGHTNESS_TEMPLATE): cv.template,
    vol.Optional(CONF_COLOR_TEMP_TEMPLATE): cv.template,
    vol.Optional(CONF_EFFECT_LIST): vol.All(cv.ensure_list, [cv.string]),
    vol.Optional(CONF_EFFECT_TEMPLATE): cv.template,
    vol.Optional(CONF_GREEN_TEMPLATE): cv.template,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_OPTIMISTIC, default=DEFAULT_OPTIMISTIC): cv.boolean,
    vol.Optional(CONF_RED_TEMPLATE): cv.template,
    vol.Optional(CONF_RETAIN, default=mqtt.DEFAULT_RETAIN): cv.boolean,
    vol.Optional(CONF_STATE_TEMPLATE): cv.template,
    vol.Optional(CONF_STATE_TOPIC): mqtt.valid_subscribe_topic,
    vol.Optional(CONF_WHITE_VALUE_TEMPLATE): cv.template,
    vol.Required(CONF_COMMAND_OFF_TEMPLATE): cv.template,
    vol.Required(CONF_COMMAND_ON_TEMPLATE): cv.template,
    vol.Required(CONF_COMMAND_TOPIC): mqtt.valid_publish_topic,
    vol.Optional(CONF_QOS, default=mqtt.DEFAULT_QOS):
        vol.All(vol.Coerce(int), vol.In([0, 1, 2])),
}).extend(mqtt.MQTT_AVAILABILITY_SCHEMA.schema)


@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Set up a MQTT Template light."""
    if discovery_info is not None:
Exemplo n.º 38
0
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
import homeassistant.util.color as color_util

_LOGGER = logging.getLogger(__name__)

SUPPORT_TIKTECK_LED = SUPPORT_BRIGHTNESS | SUPPORT_COLOR

DEVICE_SCHEMA = vol.Schema(
    {vol.Optional(CONF_NAME): cv.string, vol.Required(CONF_PASSWORD): cv.string}
)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA}}
)


def setup_platform(
    hass: HomeAssistant,
    config: ConfigType,
    add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType | None = None,
) -> None:
    """Set up the Tikteck platform."""
    lights = []
    for address, device_config in config[CONF_DEVICES].items():
        device = {}
        device["name"] = device_config[CONF_NAME]
        device["password"] = device_config[CONF_PASSWORD]
Exemplo n.º 39
0
CONF_ALLOW_LIGHTIFY_GROUPS = 'allow_lightify_groups'

DEFAULT_ALLOW_LIGHTIFY_NODES = True
DEFAULT_ALLOW_LIGHTIFY_GROUPS = True

MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)

SUPPORT_OSRAMLIGHTIFY = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP |
                         SUPPORT_EFFECT | SUPPORT_COLOR |
                         SUPPORT_TRANSITION)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Optional(CONF_ALLOW_LIGHTIFY_NODES,
                 default=DEFAULT_ALLOW_LIGHTIFY_NODES): cv.boolean,
    vol.Optional(CONF_ALLOW_LIGHTIFY_GROUPS,
                 default=DEFAULT_ALLOW_LIGHTIFY_GROUPS): cv.boolean,
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Osram Lightify lights."""
    import lightify

    host = config.get(CONF_HOST)
    add_nodes = config.get(CONF_ALLOW_LIGHTIFY_NODES)
    add_groups = config.get(CONF_ALLOW_LIGHTIFY_GROUPS)

    try:
        bridge = lightify.Lightify(host)
Exemplo n.º 40
0
CONF_DRIVER = "driver"
CONF_DRIVER_FNIP6X10AD = "FNIP6x10ad"
CONF_DRIVER_FNIP8X10A = "FNIP8x10a"
CONF_DRIVER_TYPES = [CONF_DRIVER_FNIP6X10AD, CONF_DRIVER_FNIP8X10A]

DEVICE_SCHEMA = vol.Schema({
    vol.Required(CONF_NAME): cv.string,
    vol.Optional("dimmable", default=False): cv.boolean,
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_DRIVER):
    vol.In(CONF_DRIVER_TYPES),
    vol.Required(CONF_HOST):
    cv.string,
    vol.Required(CONF_PORT):
    cv.port,
    vol.Required(CONF_DEVICES): {
        cv.string: DEVICE_SCHEMA
    },
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the light platform for each FutureNow unit."""
    lights = []
    for channel, device_config in config[CONF_DEVICES].items():
        device = {}
        device["name"] = device_config[CONF_NAME]
        device["dimmable"] = device_config["dimmable"]
        device["channel"] = channel
Exemplo n.º 41
0
                       'Rainbow mood', 'Rainbow swirl fast',
                       'Rainbow swirl', 'Random', 'Running dots',
                       'System Shutdown', 'Snake', 'Sparks Color', 'Sparks',
                       'Strobe blue', 'Strobe Raspbmc', 'Strobe white',
                       'Color traces', 'UDP multicast listener',
                       'UDP listener', 'X-Mas']

SUPPORT_HYPERION = (SUPPORT_COLOR | SUPPORT_BRIGHTNESS | SUPPORT_EFFECT)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_PORT, default=DEFAULT_PORT): cv.port,
    vol.Optional(CONF_DEFAULT_COLOR, default=DEFAULT_COLOR):
    vol.All(list, vol.Length(min=3, max=3),
            [vol.All(vol.Coerce(int), vol.Range(min=0, max=255))]),
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_PRIORITY, default=DEFAULT_PRIORITY): cv.positive_int,
    vol.Optional(CONF_HDMI_PRIORITY,
                 default=DEFAULT_HDMI_PRIORITY): cv.positive_int,
    vol.Optional(CONF_EFFECT_LIST,
                 default=DEFAULT_EFFECT_LIST): vol.All(cv.ensure_list,
                                                       [cv.string]),
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up a Hyperion server remote."""
    host = config.get(CONF_HOST)
    port = config.get(CONF_PORT)
    priority = config.get(CONF_PRIORITY)
    hdmi_priority = config.get(CONF_HDMI_PRIORITY)
    default_color = config.get(CONF_DEFAULT_COLOR)
Exemplo n.º 42
0
                         EVENT_CONTROL_TURN_OFF, EVENT_CHANGE_LEVEL)

from .vscp.util import read_reg

logger = logging.getLogger(__name__)

IDENTIFIER = 'LI'

DEVICE_SCHEMA = vol.Schema({
    vol.Required('name'): str,
    vol.Required('zone'): int,
    vol.Required('subzone'): int,
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_ENTITIES): [DEVICE_SCHEMA],
})


async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    if discovery_info is None:
        u = hass.data[DOMAIN][GATEWAY]
        async_add_entities([
            zoneLight(u, e.get(CONF_NAME), e.get(CONF_ZONE),
                      e.get(CONF_SUBZONE)) for e in config.get(CONF_ENTITIES)
        ])
        logger.debug('VSCP adding zone lights: [{}]'.format(','.join(
            [e.get(CONF_NAME) for e in config.get(CONF_ENTITIES)])))
Exemplo n.º 43
0
_LOGGER = logging.getLogger(__name__)

REQUIREMENTS = ['aiolifx==0.6.1', 'aiolifx_effects==0.1.2']

UDP_BROADCAST_PORT = 56700

DISCOVERY_INTERVAL = 60
MESSAGE_TIMEOUT = 1.0
MESSAGE_RETRIES = 8
UNAVAILABLE_GRACE = 90

CONF_SERVER = 'server'
CONF_BROADCAST = 'broadcast'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_SERVER, default='0.0.0.0'): cv.string,
    vol.Optional(CONF_BROADCAST, default='255.255.255.255'): cv.string,
})

SERVICE_LIFX_SET_STATE = 'lifx_set_state'

ATTR_INFRARED = 'infrared'
ATTR_ZONES = 'zones'
ATTR_POWER = 'power'

LIFX_SET_STATE_SCHEMA = LIGHT_TURN_ON_SCHEMA.extend({
    ATTR_INFRARED: vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255)),
    ATTR_ZONES: vol.All(cv.ensure_list, [cv.positive_int]),
    ATTR_POWER: cv.boolean,
})

SERVICE_EFFECT_PULSE = 'lifx_effect_pulse'
Exemplo n.º 44
0
import voluptuous as vol

from homeassistant.components.light import (ATTR_BRIGHTNESS, PLATFORM_SCHEMA,
                                            SUPPORT_BRIGHTNESS, Light)
from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv

from . import CONF_ADS_VAR, CONF_ADS_VAR_BRIGHTNESS, DATA_ADS, \
    AdsEntity, STATE_KEY_BRIGHTNESS, STATE_KEY_STATE

_LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = 'ADS Light'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_ADS_VAR):
    cv.string,
    vol.Optional(CONF_ADS_VAR_BRIGHTNESS):
    cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the light platform for ADS."""
    ads_hub = hass.data.get(DATA_ADS)

    ads_var_enable = config.get(CONF_ADS_VAR)
    ads_var_brightness = config.get(CONF_ADS_VAR_BRIGHTNESS)
    name = config.get(CONF_NAME)

    add_entities([AdsLight(ads_hub, ads_var_enable, ads_var_brightness, name)])
Exemplo n.º 45
0
import voluptuous as vol

from homeassistant.const import (CONF_NAME, CONF_ID, CONF_DEVICES)
from homeassistant.components.light import (
    ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light, PLATFORM_SCHEMA)
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

SUPPORT_X10 = SUPPORT_BRIGHTNESS

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_DEVICES): vol.All(cv.ensure_list, [
        {
            vol.Required(CONF_ID): cv.string,
            vol.Required(CONF_NAME): cv.string,
        }
    ]),
})


def x10_command(command):
    """Execute X10 command and check output."""
    return check_output(['heyu'] + command.split(' '), stderr=STDOUT)


def get_unit_status(code):
    """Get on/off status for given unit."""
    output = check_output('heyu onstate ' + code, shell=True)
    return int(output.decode('utf-8')[0])
Exemplo n.º 46
0
_LOGGER = logging.getLogger(__name__)

ATTR_STATION_ID = 'station_id'
ATTR_STATION_NAME = 'station_name'

CONF_STATION_ID = 'station_id'
CONF_FUEL_TYPES = 'fuel_types'
CONF_ALLOWED_FUEL_TYPES = [
    "E10", "U91", "E85", "P95", "P98", "DL", "PDL", "B20", "LPG", "CNG", "EV"
]
CONF_DEFAULT_FUEL_TYPES = ["E10", "U91"]
CONF_ATTRIBUTION = "Data provided by NSW Government FuelCheck"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_STATION_ID):
    cv.positive_int,
    vol.Optional(CONF_FUEL_TYPES, default=CONF_DEFAULT_FUEL_TYPES):
    vol.All(cv.ensure_list, [vol.In(CONF_ALLOWED_FUEL_TYPES)]),
})

MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(hours=1)

NOTIFICATION_ID = 'nsw_fuel_station_notification'
NOTIFICATION_TITLE = 'NSW Fuel Station Sensor Setup'


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the NSW Fuel Station sensor."""
    from nsw_fuel import FuelCheckClient

    station_id = config[CONF_STATION_ID]
    fuel_types = config[CONF_FUEL_TYPES]
Exemplo n.º 47
0
CONF_BROADCAST = 'broadcast'
CONF_SERVER = 'server'

SHORT_MAX = 65535

TEMP_MAX = 9000
TEMP_MAX_HASS = 500
TEMP_MIN = 2500
TEMP_MIN_HASS = 154

SUPPORT_LIFX = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR |
                SUPPORT_TRANSITION)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_SERVER): cv.string,
    vol.Optional(CONF_BROADCAST): cv.string,
})


# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the LIFX platform."""
    server_addr = config.get(CONF_SERVER)
    broadcast_addr = config.get(CONF_BROADCAST)

    lifx_library = LIFX(add_devices, server_addr, broadcast_addr)

    # Register our poll service
    track_time_change(hass, lifx_library.poll, second=[10, 40])

    lifx_library.probe()
Exemplo n.º 48
0
import voluptuous as vol

from homeassistant.const import CONF_NAME, CONF_DEVICES
from homeassistant.components.light import Light, PLATFORM_SCHEMA
from homeassistant.components.velbus import DOMAIN
import homeassistant.helpers.config_validation as cv

DEPENDENCIES = ['velbus']

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_DEVICES):
    vol.All(cv.ensure_list, [{
        vol.Required('module'): cv.positive_int,
        vol.Required('channel'): cv.positive_int,
        vol.Required(CONF_NAME): cv.string
    }])
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up Lights."""
    velbus = hass.data[DOMAIN]
    add_devices(VelbusLight(light, velbus) for light in config[CONF_DEVICES])


class VelbusLight(Light):
    """Representation of a Velbus Light."""
    def __init__(self, light, velbus):
        """Initialize a Velbus light."""
Exemplo n.º 49
0
CONF_BROADCAST = 'broadcast'
CONF_SERVER = 'server'

SHORT_MAX = 65535

TEMP_MAX = 9000
TEMP_MAX_HASS = 500
TEMP_MIN = 2500
TEMP_MIN_HASS = 154

SUPPORT_LIFX = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR |
                SUPPORT_TRANSITION)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_SERVER, default=None): cv.string,
    vol.Optional(CONF_BROADCAST, default=None): cv.string,
})


# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the LIFX platform."""
    server_addr = config.get(CONF_SERVER)
    broadcast_addr = config.get(CONF_BROADCAST)

    lifx_library = LIFX(add_devices, server_addr, broadcast_addr)

    # Register our poll service
    track_time_change(hass, lifx_library.poll, second=[10, 40])

    lifx_library.probe()
Exemplo n.º 50
0
DEFAULT_NAME = "Xiaomi Philips Light"
DATA_KEY = "light.xiaomi_miio"

CONF_MODEL = "model"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Required(CONF_HOST): cv.string,
        vol.Required(CONF_TOKEN): vol.All(cv.string, vol.Length(min=32, max=32)),
        vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
        vol.Optional(CONF_MODEL): vol.In(
            [
                "philips.light.sread1",
                "philips.light.ceiling",
                "philips.light.zyceiling",
                "philips.light.moonlight",
                "philips.light.bulb",
                "philips.light.candle",
                "philips.light.candle2",
                "philips.light.mono1",
                "philips.light.downlight",
            ]
        ),
    }
)

# The light does not accept cct values < 1
CCT_MIN = 1
CCT_MAX = 100

DELAYED_TURN_OFF_MAX_DEVIATION_SECONDS = 4
Exemplo n.º 51
0
CONF_LED_TYPE_RGBW = 'rgbw'
CONF_LED_TYPES = [CONF_LED_TYPE_SIMPLE, CONF_LED_TYPE_RGB, CONF_LED_TYPE_RGBW]

DEFAULT_BRIGHTNESS = 255
DEFAULT_COLOR = [0, 0]

SUPPORT_SIMPLE_LED = (SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION)
SUPPORT_RGB_LED = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR | SUPPORT_TRANSITION)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_LEDS): vol.All(cv.ensure_list, [
        {
            vol.Required(CONF_NAME): cv.string,
            vol.Required(CONF_DRIVER): vol.In(CONF_DRIVER_TYPES),
            vol.Required(CONF_PINS): vol.All(cv.ensure_list,
                                             [cv.positive_int]),
            vol.Required(CONF_TYPE): vol.In(CONF_LED_TYPES),
            vol.Optional(CONF_FREQUENCY): cv.positive_int,
            vol.Optional(CONF_ADDRESS): cv.byte
        }
    ])
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the PWM LED lights."""
    from pwmled.led import SimpleLed
    from pwmled.led.rgb import RgbLed
    from pwmled.led.rgbw import RgbwLed
    from pwmled.driver.gpio import GpioDriver
    from pwmled.driver.pca9685 import Pca9685Driver
Exemplo n.º 52
0
from homeassistant.components.light import (ATTR_BRIGHTNESS, PLATFORM_SCHEMA,
                                            SUPPORT_BRIGHTNESS, Light)
from homeassistant.const import CONF_HOST
import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle

REQUIREMENTS = ['greenwavereality==0.5.1']
_LOGGER = logging.getLogger(__name__)

CONF_VERSION = 'version'

SUPPORTED_FEATURES = SUPPORT_BRIGHTNESS

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Required(CONF_VERSION):
    cv.positive_int,
})

MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=1)


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Greenwave Reality Platform."""
    import greenwavereality as greenwave
    import os
    host = config.get(CONF_HOST)
    tokenfile = hass.config.path('.greenwave')
    if config.get(CONF_VERSION) == 3:
        if os.path.exists(tokenfile):
            with open(tokenfile) as tokenfile:
Exemplo n.º 53
0
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['avion==0.7']

_LOGGER = logging.getLogger(__name__)

SUPPORT_AVION_LED = (SUPPORT_BRIGHTNESS)

DEVICE_SCHEMA = vol.Schema({
    vol.Optional(CONF_NAME): cv.string,
    vol.Required(CONF_API_KEY): cv.string,
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA},
    vol.Optional(CONF_USERNAME): cv.string,
    vol.Optional(CONF_PASSWORD): cv.string,
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up an Avion switch."""
    # pylint: disable=import-error
    import avion

    lights = []
    if CONF_USERNAME in config and CONF_PASSWORD in config:
        data = avion.avion_info(config[CONF_USERNAME], config[CONF_PASSWORD])
        for location in data['locations']:
            for avion_device in location['location']['devices']:
                device = {}
Exemplo n.º 54
0
import logging

import voluptuous as vol

from homeassistant.components.light import (ATTR_BRIGHTNESS, PLATFORM_SCHEMA,
                                            Light)
from homeassistant.const import CONF_HOST
from homeassistant.exceptions import PlatformNotReady
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['niko-home-control==0.1.8']

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Niko Home Control light platform."""
    import nikohomecontrol

    host = config[CONF_HOST]

    try:
        hub = nikohomecontrol.Hub({
            'ip': host,
            'port': 8000,
            'timeout': 20000,
            'events': True
Exemplo n.º 55
0
CONF_EFFECT_LIST = 'effect_list'

CONF_FLASH_TIME_LONG = 'flash_time_long'
CONF_FLASH_TIME_SHORT = 'flash_time_short'

# Stealing some of these from the base MQTT configs.
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_BRIGHTNESS, default=DEFAULT_BRIGHTNESS): cv.boolean,
    vol.Optional(CONF_COLOR_TEMP, default=DEFAULT_COLOR_TEMP): cv.boolean,
    vol.Optional(CONF_EFFECT, default=DEFAULT_EFFECT): cv.boolean,
    vol.Optional(CONF_EFFECT_LIST): vol.All(cv.ensure_list, [cv.string]),
    vol.Optional(CONF_FLASH_TIME_SHORT, default=DEFAULT_FLASH_TIME_SHORT):
        cv.positive_int,
    vol.Optional(CONF_FLASH_TIME_LONG, default=DEFAULT_FLASH_TIME_LONG):
        cv.positive_int,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_OPTIMISTIC, default=DEFAULT_OPTIMISTIC): cv.boolean,
    vol.Optional(CONF_QOS, default=mqtt.DEFAULT_QOS):
        vol.All(vol.Coerce(int), vol.In([0, 1, 2])),
    vol.Optional(CONF_RETAIN, default=mqtt.DEFAULT_RETAIN): cv.boolean,
    vol.Optional(CONF_RGB, default=DEFAULT_RGB): cv.boolean,
    vol.Optional(CONF_STATE_TOPIC): mqtt.valid_subscribe_topic,
    vol.Optional(CONF_WHITE_VALUE, default=DEFAULT_WHITE_VALUE): cv.boolean,
    vol.Optional(CONF_XY, default=DEFAULT_XY): cv.boolean,
    vol.Required(CONF_COMMAND_TOPIC): mqtt.valid_publish_topic,
})


@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Set up a MQTT JSON Light."""
    if discovery_info is not None:
Exemplo n.º 56
0
}

FLUX_EFFECT_LIST = [
    EFFECT_RANDOM,
    ] + list(EFFECT_MAP)

DEVICE_SCHEMA = vol.Schema({
    vol.Optional(CONF_NAME): cv.string,
    vol.Optional(ATTR_MODE, default=MODE_RGBW):
        vol.All(cv.string, vol.In([MODE_RGBW, MODE_RGB])),
    vol.Optional(CONF_PROTOCOL):
        vol.All(cv.string, vol.In(['ledenet'])),
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA},
    vol.Optional(CONF_AUTOMATIC_ADD, default=False):  cv.boolean,
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the Flux lights."""
    import flux_led
    lights = []
    light_ips = []

    for ipaddr, device_config in config.get(CONF_DEVICES, {}).items():
        device = {}
        device['name'] = device_config[CONF_NAME]
        device['ipaddr'] = ipaddr
        device[CONF_PROTOCOL] = device_config.get(CONF_PROTOCOL)
        device[ATTR_MODE] = device_config[ATTR_MODE]
Exemplo n.º 57
0
import homeassistant.helpers.config_validation as cv
import homeassistant.util.color as color_util

REQUIREMENTS = ['tikteck==0.4']

_LOGGER = logging.getLogger(__name__)

SUPPORT_TIKTECK_LED = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR)

DEVICE_SCHEMA = vol.Schema({
    vol.Optional(CONF_NAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA},
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Tikteck platform."""
    lights = []
    for address, device_config in config[CONF_DEVICES].items():
        device = {}
        device['name'] = device_config[CONF_NAME]
        device['password'] = device_config[CONF_PASSWORD]
        device['address'] = address
        light = TikteckLight(device)
        if light.is_valid:
            lights.append(light)
Exemplo n.º 58
0
    'System Shutdown', 'Snake', 'Sparks Color', 'Sparks', 'Strobe blue',
    'Strobe Raspbmc', 'Strobe white', 'Color traces', 'UDP multicast listener',
    'UDP listener', 'X-Mas'
]

SUPPORT_HYPERION = (SUPPORT_COLOR | SUPPORT_BRIGHTNESS | SUPPORT_EFFECT)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Required(CONF_PORT, default=DEFAULT_PORT):
    cv.port,
    vol.Optional(CONF_DEFAULT_COLOR, default=DEFAULT_COLOR):
    vol.All(list, vol.Length(min=3, max=3),
            [vol.All(vol.Coerce(int), vol.Range(min=0, max=255))]),
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Optional(CONF_PRIORITY, default=DEFAULT_PRIORITY):
    cv.positive_int,
    vol.Optional(CONF_HDMI_PRIORITY, default=DEFAULT_HDMI_PRIORITY):
    cv.positive_int,
    vol.Optional(CONF_EFFECT_LIST, default=DEFAULT_EFFECT_LIST):
    vol.All(cv.ensure_list, [cv.string]),
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up a Hyperion server remote."""
    host = config.get(CONF_HOST)
    port = config.get(CONF_PORT)
    priority = config.get(CONF_PRIORITY)
Exemplo n.º 59
0
from homeassistant.const import CONF_NAME
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv

CONF_ADDRESS = 'address'
CONF_STATE_ADDRESS = 'state_address'
CONF_BRIGHTNESS_ADDRESS = 'brightness_address'
CONF_BRIGHTNESS_STATE_ADDRESS = 'brightness_state_address'

DEFAULT_NAME = 'KNX Light'
DEPENDENCIES = ['knx']

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_ADDRESS): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_STATE_ADDRESS): cv.string,
    vol.Optional(CONF_BRIGHTNESS_ADDRESS): cv.string,
    vol.Optional(CONF_BRIGHTNESS_STATE_ADDRESS): cv.string,
})


@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices,
                         discovery_info=None):
    """Set up light(s) for KNX platform."""
    if DATA_KNX not in hass.data \
            or not hass.data[DATA_KNX].initialized:
        return False

    if discovery_info is not None:
        async_add_devices_discovery(hass, discovery_info, async_add_devices)
Exemplo n.º 60
0
# found advice in the homeassistant creating components manual
# https://home-assistant.io/developers/creating_components/
# Import the device class from the component that you want to support
from homeassistant.components.light import Light, PLATFORM_SCHEMA

# Home Assistant depends on 3rd party packages for API specific code.

from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)

# Validation of the user's configuration
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional('serial_port', default=None):
    cv.string,
    vol.Optional('config_file', default=None):
    cv.string,
    vol.Optional('code', default=None):
    cv.string,
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Awesome Light platform."""

    # Assign configuration variables. The configuration check takes care they are
    # present.

    stick = hass.data["duofern"]['stick']

    # Add devices
    to_add = [