Added support for exposing light features (#2828)

pull/2893/head
Assaf Inbal 2016-08-16 09:07:07 +03:00 committed by Paulus Schoutsen
parent d281a7260d
commit 72ad1d8d7c
24 changed files with 250 additions and 26 deletions

View File

@ -30,6 +30,16 @@ ENTITY_ID_ALL_LIGHTS = group.ENTITY_ID_FORMAT.format('all_lights')
ENTITY_ID_FORMAT = DOMAIN + ".{}"
# Bitfield of features supported by the light entity
ATTR_SUPPORTED_FEATURES = 'supported_features'
SUPPORT_BRIGHTNESS = 1
SUPPORT_COLOR_TEMP = 2
SUPPORT_EFFECT = 4
SUPPORT_FLASH = 8
SUPPORT_RGB_COLOR = 16
SUPPORT_TRANSITION = 32
SUPPORT_XY_COLOR = 64
# Integer that represents transition time in seconds to make change.
ATTR_TRANSITION = "transition"
@ -63,6 +73,7 @@ PROP_TO_ATTR = {
'color_temp': ATTR_COLOR_TEMP,
'rgb_color': ATTR_RGB_COLOR,
'xy_color': ATTR_XY_COLOR,
'supported_features': ATTR_SUPPORTED_FEATURES,
}
# Service call validation schemas
@ -279,7 +290,7 @@ class Light(ToggleEntity):
if self.is_on:
for prop, attr in PROP_TO_ATTR.items():
value = getattr(self, prop)
if value:
if value is not None:
data[attr] = value
if ATTR_RGB_COLOR not in data and ATTR_XY_COLOR in data and \
@ -287,5 +298,12 @@ class Light(ToggleEntity):
data[ATTR_RGB_COLOR] = color_util.color_xy_brightness_to_RGB(
data[ATTR_XY_COLOR][0], data[ATTR_XY_COLOR][1],
data[ATTR_BRIGHTNESS])
else:
data[ATTR_SUPPORTED_FEATURES] = self.supported_features
return data
@property
def supported_features(self):
"""Flag supported features."""
return 0

View File

@ -6,7 +6,8 @@ https://home-assistant.io/components/light.blinksticklight/
"""
import logging
from homeassistant.components.light import ATTR_RGB_COLOR, Light
from homeassistant.components.light import (ATTR_RGB_COLOR, SUPPORT_RGB_COLOR,
Light)
_LOGGER = logging.getLogger(__name__)
@ -14,6 +15,9 @@ _LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ["blinkstick==1.1.7"]
SUPPORT_BLINKSTICK = SUPPORT_RGB_COLOR
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Add device specified by serial number."""
@ -54,6 +58,11 @@ class BlinkStickLight(Light):
"""Check whether any of the LEDs colors are non-zero."""
return sum(self._rgb_color) > 0
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_BLINKSTICK
def update(self):
"""Read back the device state."""
self._rgb_color = self._stick.get_color()

View File

@ -7,7 +7,8 @@ https://home-assistant.io/components/demo/
import random
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, Light)
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, Light)
LIGHT_COLORS = [
[237, 224, 33],
@ -16,6 +17,8 @@ LIGHT_COLORS = [
LIGHT_TEMPS = [240, 380]
SUPPORT_DEMO = SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup the demo light platform."""
@ -68,6 +71,11 @@ class DemoLight(Light):
"""Return true if light is on."""
return self._state
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_DEMO
def turn_on(self, **kwargs):
"""Turn the light on."""
self._state = True

View File

@ -7,7 +7,8 @@ https://home-assistant.io/components/light.enocean/
import logging
import math
from homeassistant.components.light import Light, ATTR_BRIGHTNESS
from homeassistant.components.light import (Light, ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS)
from homeassistant.const import CONF_NAME
from homeassistant.components import enocean
@ -19,6 +20,8 @@ DEPENDENCIES = ["enocean"]
CONF_ID = "id"
CONF_SENDER_ID = "sender_id"
SUPPORT_ENOCEAN = SUPPORT_BRIGHTNESS
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the EnOcean light platform."""
@ -61,6 +64,11 @@ class EnOceanLight(enocean.EnOceanDevice, Light):
"""If light is on."""
return self._on_state
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_ENOCEAN
def turn_on(self, **kwargs):
"""Turn the light source on or sets a specific dimmer value."""
brightness = kwargs.get(ATTR_BRIGHTNESS)

View File

@ -10,7 +10,8 @@ import socket
import voluptuous as vol
from homeassistant.components.light import (ATTR_BRIGHTNESS, ATTR_RGB_COLOR,
Light)
SUPPORT_BRIGHTNESS,
SUPPORT_RGB_COLOR, Light)
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['https://github.com/Danielhiversen/flux_led/archive/0.6.zip'
@ -30,6 +31,8 @@ PLATFORM_SCHEMA = vol.Schema({
vol.Optional('automatic_add', default=False): cv.boolean,
}, extra=vol.ALLOW_EXTRA)
SUPPORT_FLUX_LED = SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup the Flux lights."""
@ -110,6 +113,11 @@ class FluxLight(Light):
"""Return the color property."""
return self._bulb.getRgb()
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_FLUX_LED
def turn_on(self, **kwargs):
"""Turn the specified or all lights on."""
if not self.is_on:

View File

@ -5,7 +5,8 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.homematic/
"""
import logging
from homeassistant.components.light import (ATTR_BRIGHTNESS, Light)
from homeassistant.components.light import (ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS, Light)
from homeassistant.const import STATE_UNKNOWN
import homeassistant.components.homematic as homematic
@ -13,6 +14,8 @@ _LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['homematic']
SUPPORT_HOMEMATIC = SUPPORT_BRIGHTNESS
def setup_platform(hass, config, add_callback_devices, discovery_info=None):
"""Setup the Homematic light platform."""
@ -46,6 +49,11 @@ class HMLight(homematic.HMDevice, Light):
except TypeError:
return False
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_HOMEMATIC
def turn_on(self, **kwargs):
"""Turn the light on."""
if not self.available:

View File

@ -17,7 +17,9 @@ import homeassistant.util.color as color_util
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, ATTR_RGB_COLOR,
ATTR_TRANSITION, ATTR_XY_COLOR, EFFECT_COLORLOOP, EFFECT_RANDOM,
FLASH_LONG, FLASH_SHORT, Light)
FLASH_LONG, FLASH_SHORT, SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT, SUPPORT_FLASH, SUPPORT_RGB_COLOR, SUPPORT_TRANSITION,
SUPPORT_XY_COLOR, Light)
from homeassistant.const import CONF_FILENAME, CONF_HOST, DEVICE_DEFAULT_NAME
from homeassistant.loader import get_component
@ -27,6 +29,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)
# Map ip to request id for configuring
_CONFIGURING = {}
@ -228,6 +234,11 @@ class HueLight(Light):
else:
return self.info['state']['reachable'] and self.info['state']['on']
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_HUE
def turn_on(self, **kwargs):
"""Turn the specified or all lights on."""
command = {'on': True}

View File

@ -8,12 +8,15 @@ import json
import logging
import socket
from homeassistant.components.light import ATTR_RGB_COLOR, Light
from homeassistant.components.light import (ATTR_RGB_COLOR, SUPPORT_RGB_COLOR,
Light)
from homeassistant.const import CONF_HOST
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = []
SUPPORT_HYPERION = SUPPORT_RGB_COLOR
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup a Hyperion server remote."""
@ -53,6 +56,11 @@ class Hyperion(Light):
"""Return true if not black."""
return self._rgb_color != [0, 0, 0]
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_HYPERION
def turn_on(self, **kwargs):
"""Turn the lights on."""
if ATTR_RGB_COLOR in kwargs:

View File

@ -5,7 +5,10 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/insteon_hub/
"""
from homeassistant.components.insteon_hub import INSTEON
from homeassistant.components.light import ATTR_BRIGHTNESS, Light
from homeassistant.components.light import (ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS, Light)
SUPPORT_INSTEON_HUB = SUPPORT_BRIGHTNESS
def setup_platform(hass, config, add_devices, discovery_info=None):
@ -55,6 +58,11 @@ class InsteonToggleDevice(Light):
"""Return the boolean response if the node is on."""
return self._value != 0
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_INSTEON_HUB
def turn_on(self, **kwargs):
"""Turn device on."""
if ATTR_BRIGHTNESS in kwargs:

View File

@ -8,9 +8,13 @@ import logging
from homeassistant.components.isy994 import (
HIDDEN_STRING, ISY, SENSOR_STRING, ISYDeviceABC)
from homeassistant.components.light import ATTR_BRIGHTNESS
from homeassistant.components.light import (ATTR_BRIGHTNESS,
ATTR_SUPPORTED_FEATURES,
SUPPORT_BRIGHTNESS)
from homeassistant.const import STATE_OFF, STATE_ON
SUPPORT_ISY994 = SUPPORT_BRIGHTNESS
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the ISY994 platform."""
@ -36,10 +40,18 @@ class ISYLightDevice(ISYDeviceABC):
_domain = 'light'
_dtype = 'analog'
_attrs = {ATTR_BRIGHTNESS: 'value'}
_attrs = {
ATTR_BRIGHTNESS: 'value',
ATTR_SUPPORTED_FEATURES: 'supported_features',
}
_onattrs = [ATTR_BRIGHTNESS]
_states = [STATE_ON, STATE_OFF]
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_ISY994
def _attr_filter(self, attr):
"""Filter brightness out of entity while off."""
if ATTR_BRIGHTNESS in attr and not self.is_on:

View File

@ -8,7 +8,9 @@ import colorsys
import logging
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, ATTR_TRANSITION, Light)
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, ATTR_TRANSITION,
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR,
SUPPORT_TRANSITION, Light)
from homeassistant.helpers.event import track_time_change
_LOGGER = logging.getLogger(__name__)
@ -24,6 +26,9 @@ TEMP_MAX = 9000 # lifx maximum temperature
TEMP_MIN_HASS = 154 # home assistant minimum temperature
TEMP_MAX_HASS = 500 # home assistant maximum temperature
SUPPORT_LIFX = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR |
SUPPORT_TRANSITION)
class LIFX():
"""Representation of a LIFX light."""
@ -185,6 +190,11 @@ class LIFXLight(Light):
_LOGGER.debug("is_on: %d", self._power)
return self._power != 0
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_LIFX
def turn_on(self, **kwargs):
"""Turn the device on."""
if ATTR_TRANSITION in kwargs:

View File

@ -9,7 +9,9 @@ import logging
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, ATTR_RGB_COLOR,
ATTR_TRANSITION, EFFECT_COLORLOOP, EFFECT_WHITE, FLASH_LONG, Light)
ATTR_TRANSITION, EFFECT_COLORLOOP, EFFECT_WHITE, FLASH_LONG,
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_EFFECT, SUPPORT_FLASH,
SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, Light)
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['limitlessled==1.0.0']
@ -20,6 +22,12 @@ DEFAULT_VERSION = 5
DEFAULT_LED_TYPE = 'rgbw'
WHITE = [255, 255, 255]
SUPPORT_LIMITLESSLED_WHITE = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP |
SUPPORT_TRANSITION)
SUPPORT_LIMITLESSLED_RGB = (SUPPORT_BRIGHTNESS | SUPPORT_EFFECT |
SUPPORT_FLASH | SUPPORT_RGB_COLOR |
SUPPORT_TRANSITION)
def rewrite_legacy(config):
"""Rewrite legacy configuration to new format."""
@ -168,6 +176,11 @@ class LimitlessLEDWhiteGroup(LimitlessLEDGroup):
"""Return the temperature property."""
return self._temperature
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_LIMITLESSLED_WHITE
@state(True)
def turn_on(self, transition_time, pipeline, **kwargs):
"""Turn on (or adjust property of) a group."""
@ -203,6 +216,11 @@ class LimitlessLEDRGBWGroup(LimitlessLEDGroup):
"""Return the color property."""
return self._color
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_LIMITLESSLED_RGB
@state(True)
def turn_on(self, transition_time, pipeline, **kwargs):
"""Turn on (or adjust property of) a group."""

View File

@ -11,7 +11,8 @@ import voluptuous as vol
import homeassistant.components.mqtt as mqtt
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_RGB_COLOR, Light)
ATTR_BRIGHTNESS, ATTR_RGB_COLOR, SUPPORT_BRIGHTNESS, SUPPORT_RGB_COLOR,
Light)
from homeassistant.const import CONF_NAME, CONF_OPTIMISTIC, CONF_VALUE_TEMPLATE
from homeassistant.components.mqtt import (
CONF_STATE_TOPIC, CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN)
@ -108,6 +109,11 @@ class MqttLight(Light):
topic["brightness_state_topic"] is None)
self._brightness_scale = brightness_scale
self._state = False
self._supported_features = 0
self._supported_features |= (
topic['rgb_state_topic'] is not None and SUPPORT_RGB_COLOR)
self._supported_features |= (
topic['brightness_state_topic'] is not None and SUPPORT_BRIGHTNESS)
templates = {key: ((lambda value: value) if tpl is None else
partial(render_with_possible_json_value, hass, tpl))
@ -188,6 +194,11 @@ class MqttLight(Light):
"""Return true if we do optimistic updates."""
return self._optimistic
@property
def supported_features(self):
"""Flag supported features."""
return self._supported_features
def turn_on(self, **kwargs):
"""Turn the device on."""
should_update = False

View File

@ -12,7 +12,8 @@ import voluptuous as vol
import homeassistant.components.mqtt as mqtt
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ATTR_TRANSITION,
ATTR_FLASH, FLASH_LONG, FLASH_SHORT, Light)
ATTR_FLASH, FLASH_LONG, FLASH_SHORT, SUPPORT_BRIGHTNESS, SUPPORT_FLASH,
SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, Light)
from homeassistant.const import CONF_NAME, CONF_OPTIMISTIC, CONF_PLATFORM
from homeassistant.components.mqtt import (
CONF_STATE_TOPIC, CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN)
@ -36,6 +37,9 @@ CONF_RGB = "rgb"
CONF_FLASH_TIME_SHORT = "flash_time_short"
CONF_FLASH_TIME_LONG = "flash_time_long"
SUPPORT_MQTT_JSON = (SUPPORT_BRIGHTNESS | SUPPORT_FLASH | SUPPORT_RGB_COLOR |
SUPPORT_TRANSITION)
# Stealing some of these from the base MQTT configs.
PLATFORM_SCHEMA = vol.Schema({
vol.Required(CONF_PLATFORM): DOMAIN,

View File

@ -9,7 +9,8 @@ import logging
from homeassistant.components import mysensors
from homeassistant.components.light import (ATTR_BRIGHTNESS, ATTR_RGB_COLOR,
Light)
SUPPORT_BRIGHTNESS,
SUPPORT_RGB_COLOR, Light)
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.util.color import rgb_hex_to_rgb_list
@ -18,6 +19,8 @@ ATTR_RGB_WHITE = 'rgb_white'
ATTR_VALUE = 'value'
ATTR_VALUE_TYPE = 'value_type'
SUPPORT_MYSENSORS = SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the mysensors platform for sensors."""
@ -87,6 +90,11 @@ class MySensorsLight(mysensors.MySensorsDeviceEntity, Light):
"""Return true if device is on."""
return self._state
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_MYSENSORS
def _turn_on_light(self):
"""Turn on light child device."""
set_req = self.gateway.const.SetReq

View File

@ -15,7 +15,11 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
ATTR_RGB_COLOR,
ATTR_TRANSITION
ATTR_TRANSITION,
SUPPORT_BRIGHTNESS,
SUPPORT_COLOR_TEMP,
SUPPORT_RGB_COLOR,
SUPPORT_TRANSITION,
)
_LOGGER = logging.getLogger(__name__)
@ -28,6 +32,9 @@ TEMP_MAX_HASS = 500 # home assistant maximum temperature
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
SUPPORT_OSRAMLIGHTIFY = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP |
SUPPORT_RGB_COLOR | SUPPORT_TRANSITION)
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup Osram Lightify lights."""
@ -114,6 +121,11 @@ class OsramLightifyLight(Light):
self._light.name(), self._light.on())
return self._light.on()
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_OSRAMLIGHTIFY
def turn_on(self, **kwargs):
"""Turn the device on."""
brightness = 100

View File

@ -7,7 +7,8 @@ https://home-assistant.io/components/light.rfxtrx/
import logging
import homeassistant.components.rfxtrx as rfxtrx
from homeassistant.components.light import ATTR_BRIGHTNESS, Light
from homeassistant.components.light import (ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS, Light)
DEPENDENCIES = ['rfxtrx']
@ -15,6 +16,8 @@ _LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = rfxtrx.DEFAULT_SCHEMA
SUPPORT_RFXTRX = SUPPORT_BRIGHTNESS
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup the RFXtrx platform."""
@ -48,6 +51,11 @@ class RfxtrxLight(rfxtrx.RfxtrxDevice, Light):
"""Return the brightness of this light between 0..255."""
return self._brightness
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_RFXTRX
def turn_on(self, **kwargs):
"""Turn the light on."""
brightness = kwargs.get(ATTR_BRIGHTNESS)

View File

@ -7,13 +7,16 @@ https://home-assistant.io/components/light.tellstick/
import voluptuous as vol
from homeassistant.components import tellstick
from homeassistant.components.light import ATTR_BRIGHTNESS, Light
from homeassistant.components.light import (ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS, Light)
from homeassistant.components.tellstick import (DEFAULT_SIGNAL_REPETITIONS,
ATTR_DISCOVER_DEVICES,
ATTR_DISCOVER_CONFIG)
PLATFORM_SCHEMA = vol.Schema({vol.Required("platform"): tellstick.DOMAIN})
SUPPORT_TELLSTICK = SUPPORT_BRIGHTNESS
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
@ -51,6 +54,11 @@ class TellstickLight(tellstick.TellstickDevice, Light):
"""Return the brightness of this light between 0..255."""
return self._brightness
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_TELLSTICK
def set_tellstick_state(self, last_command_sent, last_data_sent):
"""Update the internal representation of the switch."""
from tellcore.constants import TELLSTICK_TURNON, TELLSTICK_DIM

View File

@ -6,7 +6,8 @@ https://home-assistant.io/components/light.vera/
"""
import logging
from homeassistant.components.light import ATTR_BRIGHTNESS, Light
from homeassistant.components.light import (ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS, Light)
from homeassistant.const import (
STATE_OFF, STATE_ON)
from homeassistant.components.vera import (
@ -16,6 +17,8 @@ DEPENDENCIES = ['vera']
_LOGGER = logging.getLogger(__name__)
SUPPORT_VERA = SUPPORT_BRIGHTNESS
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
@ -38,6 +41,11 @@ class VeraLight(VeraDevice, Light):
if self.vera_device.is_dimmable:
return self.vera_device.get_brightness()
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_VERA
def turn_on(self, **kwargs):
"""Turn the light on."""
if ATTR_BRIGHTNESS in kwargs and self.vera_device.is_dimmable:

View File

@ -11,7 +11,8 @@ import homeassistant.util as util
import homeassistant.util.color as color_util
from homeassistant.components.light import (
Light, ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, ATTR_TRANSITION,
ATTR_XY_COLOR)
ATTR_XY_COLOR, SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR,
SUPPORT_TRANSITION, SUPPORT_XY_COLOR)
DEPENDENCIES = ['wemo']
@ -20,6 +21,9 @@ MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
_LOGGER = logging.getLogger(__name__)
SUPPORT_WEMO = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR |
SUPPORT_TRANSITION | SUPPORT_XY_COLOR)
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup WeMo bridges and register connected lights."""
@ -96,6 +100,11 @@ class WemoLight(Light):
"""True if device is on."""
return self.device.state['onoff'] != 0
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_WEMO
def turn_on(self, **kwargs):
"""Turn the light on."""
transitiontime = int(kwargs.get(ATTR_TRANSITION, 0))

View File

@ -7,7 +7,8 @@ https://home-assistant.io/components/light.wink/
import logging
from homeassistant.components.light import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, \
Light, ATTR_RGB_COLOR
ATTR_RGB_COLOR, SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, \
SUPPORT_RGB_COLOR, Light
from homeassistant.components.wink import WinkDevice
from homeassistant.const import CONF_ACCESS_TOKEN
from homeassistant.util import color as color_util
@ -16,6 +17,8 @@ from homeassistant.util.color import \
REQUIREMENTS = ['python-wink==0.7.11', 'pubnub==3.8.2']
SUPPORT_WINK = SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup Wink lights."""
@ -68,6 +71,11 @@ class WinkLight(WinkDevice, Light):
return color_util.color_temperature_kelvin_to_mired(
self.wink.color_temperature_kelvin())
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_WINK
# pylint: disable=too-few-public-methods
def turn_on(self, **kwargs):
"""Turn the switch on."""

View File

@ -6,10 +6,13 @@ https://home-assistant.io/components/light.x10/
"""
import logging
from subprocess import check_output, CalledProcessError, STDOUT
from homeassistant.components.light import ATTR_BRIGHTNESS, Light
from homeassistant.components.light import (ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS, Light)
_LOGGER = logging.getLogger(__name__)
SUPPORT_X10 = SUPPORT_BRIGHTNESS
def x10_command(command):
"""Execute X10 command and check output."""
@ -64,6 +67,11 @@ class X10Light(Light):
"""Return true if light is on."""
return self._is_on
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_X10
def turn_on(self, **kwargs):
"""Instruct the light to turn on."""
x10_command("on " + self._id)

View File

@ -10,7 +10,8 @@ import logging
# pylint: disable=import-error
from threading import Timer
from homeassistant.components.light import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, \
ATTR_RGB_COLOR, DOMAIN, Light
ATTR_RGB_COLOR, SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, \
SUPPORT_RGB_COLOR, DOMAIN, Light
from homeassistant.components import zwave
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.util.color import HASS_COLOR_MAX, HASS_COLOR_MIN, \
@ -41,6 +42,8 @@ TEMP_MID_HASS = (HASS_COLOR_MAX - HASS_COLOR_MIN) / 2 + HASS_COLOR_MIN
TEMP_WARM_HASS = (HASS_COLOR_MAX - HASS_COLOR_MIN) / 3 * 2 + HASS_COLOR_MIN
TEMP_COLD_HASS = (HASS_COLOR_MAX - HASS_COLOR_MIN) / 3 + HASS_COLOR_MIN
SUPPORT_ZWAVE = SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Find and add Z-Wave lights."""
@ -137,6 +140,11 @@ class ZwaveDimmer(zwave.ZWaveDeviceEntity, Light):
"""Return true if device is on."""
return self._state == STATE_ON
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_ZWAVE
def turn_on(self, **kwargs):
"""Turn the device on."""
if ATTR_BRIGHTNESS in kwargs:

View File

@ -10,7 +10,8 @@ import voluptuous as vol
from homeassistant.const import (EVENT_HOMEASSISTANT_START,
EVENT_HOMEASSISTANT_STOP)
from homeassistant.helpers.discovery import load_platform
from homeassistant.components.light import ATTR_BRIGHTNESS, Light
from homeassistant.components.light import (ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS, Light)
from homeassistant.components.switch import SwitchDevice
DOMAIN = 'qwikswitch'
@ -29,6 +30,8 @@ CONFIG_SCHEMA = vol.Schema({
QSUSB = {}
SUPPORT_QWIKSWITCH = SUPPORT_BRIGHTNESS
class QSToggleEntity(object):
"""Representation of a Qwikswitch Entity.
@ -108,7 +111,10 @@ class QSSwitch(QSToggleEntity, SwitchDevice):
class QSLight(QSToggleEntity, Light):
"""Light based on a Qwikswitch relay/dimmer module."""
pass
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_QWIKSWITCH
# pylint: disable=too-many-locals