Added support for exposing light features (#2828)
parent
d281a7260d
commit
72ad1d8d7c
|
@ -30,6 +30,16 @@ ENTITY_ID_ALL_LIGHTS = group.ENTITY_ID_FORMAT.format('all_lights')
|
||||||
|
|
||||||
ENTITY_ID_FORMAT = DOMAIN + ".{}"
|
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.
|
# Integer that represents transition time in seconds to make change.
|
||||||
ATTR_TRANSITION = "transition"
|
ATTR_TRANSITION = "transition"
|
||||||
|
|
||||||
|
@ -63,6 +73,7 @@ PROP_TO_ATTR = {
|
||||||
'color_temp': ATTR_COLOR_TEMP,
|
'color_temp': ATTR_COLOR_TEMP,
|
||||||
'rgb_color': ATTR_RGB_COLOR,
|
'rgb_color': ATTR_RGB_COLOR,
|
||||||
'xy_color': ATTR_XY_COLOR,
|
'xy_color': ATTR_XY_COLOR,
|
||||||
|
'supported_features': ATTR_SUPPORTED_FEATURES,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Service call validation schemas
|
# Service call validation schemas
|
||||||
|
@ -279,7 +290,7 @@ class Light(ToggleEntity):
|
||||||
if self.is_on:
|
if self.is_on:
|
||||||
for prop, attr in PROP_TO_ATTR.items():
|
for prop, attr in PROP_TO_ATTR.items():
|
||||||
value = getattr(self, prop)
|
value = getattr(self, prop)
|
||||||
if value:
|
if value is not None:
|
||||||
data[attr] = value
|
data[attr] = value
|
||||||
|
|
||||||
if ATTR_RGB_COLOR not in data and ATTR_XY_COLOR in data and \
|
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_RGB_COLOR] = color_util.color_xy_brightness_to_RGB(
|
||||||
data[ATTR_XY_COLOR][0], data[ATTR_XY_COLOR][1],
|
data[ATTR_XY_COLOR][0], data[ATTR_XY_COLOR][1],
|
||||||
data[ATTR_BRIGHTNESS])
|
data[ATTR_BRIGHTNESS])
|
||||||
|
else:
|
||||||
|
data[ATTR_SUPPORTED_FEATURES] = self.supported_features
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return 0
|
||||||
|
|
|
@ -6,7 +6,8 @@ https://home-assistant.io/components/light.blinksticklight/
|
||||||
"""
|
"""
|
||||||
import logging
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -14,6 +15,9 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
REQUIREMENTS = ["blinkstick==1.1.7"]
|
REQUIREMENTS = ["blinkstick==1.1.7"]
|
||||||
|
|
||||||
|
|
||||||
|
SUPPORT_BLINKSTICK = SUPPORT_RGB_COLOR
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
"""Add device specified by serial number."""
|
"""Add device specified by serial number."""
|
||||||
|
@ -54,6 +58,11 @@ class BlinkStickLight(Light):
|
||||||
"""Check whether any of the LEDs colors are non-zero."""
|
"""Check whether any of the LEDs colors are non-zero."""
|
||||||
return sum(self._rgb_color) > 0
|
return sum(self._rgb_color) > 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_BLINKSTICK
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Read back the device state."""
|
"""Read back the device state."""
|
||||||
self._rgb_color = self._stick.get_color()
|
self._rgb_color = self._stick.get_color()
|
||||||
|
|
|
@ -7,7 +7,8 @@ https://home-assistant.io/components/demo/
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
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 = [
|
LIGHT_COLORS = [
|
||||||
[237, 224, 33],
|
[237, 224, 33],
|
||||||
|
@ -16,6 +17,8 @@ LIGHT_COLORS = [
|
||||||
|
|
||||||
LIGHT_TEMPS = [240, 380]
|
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):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
"""Setup the demo light platform."""
|
"""Setup the demo light platform."""
|
||||||
|
@ -68,6 +71,11 @@ class DemoLight(Light):
|
||||||
"""Return true if light is on."""
|
"""Return true if light is on."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_DEMO
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
self._state = True
|
self._state = True
|
||||||
|
|
|
@ -7,7 +7,8 @@ https://home-assistant.io/components/light.enocean/
|
||||||
import logging
|
import logging
|
||||||
import math
|
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.const import CONF_NAME
|
||||||
from homeassistant.components import enocean
|
from homeassistant.components import enocean
|
||||||
|
|
||||||
|
@ -19,6 +20,8 @@ DEPENDENCIES = ["enocean"]
|
||||||
CONF_ID = "id"
|
CONF_ID = "id"
|
||||||
CONF_SENDER_ID = "sender_id"
|
CONF_SENDER_ID = "sender_id"
|
||||||
|
|
||||||
|
SUPPORT_ENOCEAN = SUPPORT_BRIGHTNESS
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the EnOcean light platform."""
|
"""Setup the EnOcean light platform."""
|
||||||
|
@ -61,6 +64,11 @@ class EnOceanLight(enocean.EnOceanDevice, Light):
|
||||||
"""If light is on."""
|
"""If light is on."""
|
||||||
return self._on_state
|
return self._on_state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_ENOCEAN
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the light source on or sets a specific dimmer value."""
|
"""Turn the light source on or sets a specific dimmer value."""
|
||||||
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
||||||
|
|
|
@ -10,7 +10,8 @@ import socket
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.light import (ATTR_BRIGHTNESS, ATTR_RGB_COLOR,
|
from homeassistant.components.light import (ATTR_BRIGHTNESS, ATTR_RGB_COLOR,
|
||||||
Light)
|
SUPPORT_BRIGHTNESS,
|
||||||
|
SUPPORT_RGB_COLOR, Light)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['https://github.com/Danielhiversen/flux_led/archive/0.6.zip'
|
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,
|
vol.Optional('automatic_add', default=False): cv.boolean,
|
||||||
}, extra=vol.ALLOW_EXTRA)
|
}, extra=vol.ALLOW_EXTRA)
|
||||||
|
|
||||||
|
SUPPORT_FLUX_LED = SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
"""Setup the Flux lights."""
|
"""Setup the Flux lights."""
|
||||||
|
@ -110,6 +113,11 @@ class FluxLight(Light):
|
||||||
"""Return the color property."""
|
"""Return the color property."""
|
||||||
return self._bulb.getRgb()
|
return self._bulb.getRgb()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_FLUX_LED
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the specified or all lights on."""
|
"""Turn the specified or all lights on."""
|
||||||
if not self.is_on:
|
if not self.is_on:
|
||||||
|
|
|
@ -5,7 +5,8 @@ For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/light.homematic/
|
https://home-assistant.io/components/light.homematic/
|
||||||
"""
|
"""
|
||||||
import logging
|
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
|
from homeassistant.const import STATE_UNKNOWN
|
||||||
import homeassistant.components.homematic as homematic
|
import homeassistant.components.homematic as homematic
|
||||||
|
|
||||||
|
@ -13,6 +14,8 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEPENDENCIES = ['homematic']
|
DEPENDENCIES = ['homematic']
|
||||||
|
|
||||||
|
SUPPORT_HOMEMATIC = SUPPORT_BRIGHTNESS
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_callback_devices, discovery_info=None):
|
def setup_platform(hass, config, add_callback_devices, discovery_info=None):
|
||||||
"""Setup the Homematic light platform."""
|
"""Setup the Homematic light platform."""
|
||||||
|
@ -46,6 +49,11 @@ class HMLight(homematic.HMDevice, Light):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_HOMEMATIC
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
if not self.available:
|
if not self.available:
|
||||||
|
|
|
@ -17,7 +17,9 @@ import homeassistant.util.color as color_util
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, ATTR_RGB_COLOR,
|
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, ATTR_RGB_COLOR,
|
||||||
ATTR_TRANSITION, ATTR_XY_COLOR, EFFECT_COLORLOOP, EFFECT_RANDOM,
|
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.const import CONF_FILENAME, CONF_HOST, DEVICE_DEFAULT_NAME
|
||||||
from homeassistant.loader import get_component
|
from homeassistant.loader import get_component
|
||||||
|
|
||||||
|
@ -27,6 +29,10 @@ MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
|
||||||
|
|
||||||
PHUE_CONFIG_FILE = "phue.conf"
|
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
|
# Map ip to request id for configuring
|
||||||
_CONFIGURING = {}
|
_CONFIGURING = {}
|
||||||
|
@ -228,6 +234,11 @@ class HueLight(Light):
|
||||||
else:
|
else:
|
||||||
return self.info['state']['reachable'] and self.info['state']['on']
|
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):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the specified or all lights on."""
|
"""Turn the specified or all lights on."""
|
||||||
command = {'on': True}
|
command = {'on': True}
|
||||||
|
|
|
@ -8,12 +8,15 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import socket
|
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
|
from homeassistant.const import CONF_HOST
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
REQUIREMENTS = []
|
REQUIREMENTS = []
|
||||||
|
|
||||||
|
SUPPORT_HYPERION = SUPPORT_RGB_COLOR
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
"""Setup a Hyperion server remote."""
|
"""Setup a Hyperion server remote."""
|
||||||
|
@ -53,6 +56,11 @@ class Hyperion(Light):
|
||||||
"""Return true if not black."""
|
"""Return true if not black."""
|
||||||
return self._rgb_color != [0, 0, 0]
|
return self._rgb_color != [0, 0, 0]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_HYPERION
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the lights on."""
|
"""Turn the lights on."""
|
||||||
if ATTR_RGB_COLOR in kwargs:
|
if ATTR_RGB_COLOR in kwargs:
|
||||||
|
|
|
@ -5,7 +5,10 @@ For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/insteon_hub/
|
https://home-assistant.io/components/insteon_hub/
|
||||||
"""
|
"""
|
||||||
from homeassistant.components.insteon_hub import INSTEON
|
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):
|
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 the boolean response if the node is on."""
|
||||||
return self._value != 0
|
return self._value != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_INSTEON_HUB
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn device on."""
|
"""Turn device on."""
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
|
|
|
@ -8,9 +8,13 @@ import logging
|
||||||
|
|
||||||
from homeassistant.components.isy994 import (
|
from homeassistant.components.isy994 import (
|
||||||
HIDDEN_STRING, ISY, SENSOR_STRING, ISYDeviceABC)
|
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
|
from homeassistant.const import STATE_OFF, STATE_ON
|
||||||
|
|
||||||
|
SUPPORT_ISY994 = SUPPORT_BRIGHTNESS
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the ISY994 platform."""
|
"""Setup the ISY994 platform."""
|
||||||
|
@ -36,10 +40,18 @@ class ISYLightDevice(ISYDeviceABC):
|
||||||
|
|
||||||
_domain = 'light'
|
_domain = 'light'
|
||||||
_dtype = 'analog'
|
_dtype = 'analog'
|
||||||
_attrs = {ATTR_BRIGHTNESS: 'value'}
|
_attrs = {
|
||||||
|
ATTR_BRIGHTNESS: 'value',
|
||||||
|
ATTR_SUPPORTED_FEATURES: 'supported_features',
|
||||||
|
}
|
||||||
_onattrs = [ATTR_BRIGHTNESS]
|
_onattrs = [ATTR_BRIGHTNESS]
|
||||||
_states = [STATE_ON, STATE_OFF]
|
_states = [STATE_ON, STATE_OFF]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_ISY994
|
||||||
|
|
||||||
def _attr_filter(self, attr):
|
def _attr_filter(self, attr):
|
||||||
"""Filter brightness out of entity while off."""
|
"""Filter brightness out of entity while off."""
|
||||||
if ATTR_BRIGHTNESS in attr and not self.is_on:
|
if ATTR_BRIGHTNESS in attr and not self.is_on:
|
||||||
|
|
|
@ -8,7 +8,9 @@ import colorsys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
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
|
from homeassistant.helpers.event import track_time_change
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -24,6 +26,9 @@ TEMP_MAX = 9000 # lifx maximum temperature
|
||||||
TEMP_MIN_HASS = 154 # home assistant minimum temperature
|
TEMP_MIN_HASS = 154 # home assistant minimum temperature
|
||||||
TEMP_MAX_HASS = 500 # home assistant maximum temperature
|
TEMP_MAX_HASS = 500 # home assistant maximum temperature
|
||||||
|
|
||||||
|
SUPPORT_LIFX = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR |
|
||||||
|
SUPPORT_TRANSITION)
|
||||||
|
|
||||||
|
|
||||||
class LIFX():
|
class LIFX():
|
||||||
"""Representation of a LIFX light."""
|
"""Representation of a LIFX light."""
|
||||||
|
@ -185,6 +190,11 @@ class LIFXLight(Light):
|
||||||
_LOGGER.debug("is_on: %d", self._power)
|
_LOGGER.debug("is_on: %d", self._power)
|
||||||
return self._power != 0
|
return self._power != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_LIFX
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
if ATTR_TRANSITION in kwargs:
|
if ATTR_TRANSITION in kwargs:
|
||||||
|
|
|
@ -9,7 +9,9 @@ import logging
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, ATTR_RGB_COLOR,
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
REQUIREMENTS = ['limitlessled==1.0.0']
|
REQUIREMENTS = ['limitlessled==1.0.0']
|
||||||
|
@ -20,6 +22,12 @@ DEFAULT_VERSION = 5
|
||||||
DEFAULT_LED_TYPE = 'rgbw'
|
DEFAULT_LED_TYPE = 'rgbw'
|
||||||
WHITE = [255, 255, 255]
|
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):
|
def rewrite_legacy(config):
|
||||||
"""Rewrite legacy configuration to new format."""
|
"""Rewrite legacy configuration to new format."""
|
||||||
|
@ -168,6 +176,11 @@ class LimitlessLEDWhiteGroup(LimitlessLEDGroup):
|
||||||
"""Return the temperature property."""
|
"""Return the temperature property."""
|
||||||
return self._temperature
|
return self._temperature
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_LIMITLESSLED_WHITE
|
||||||
|
|
||||||
@state(True)
|
@state(True)
|
||||||
def turn_on(self, transition_time, pipeline, **kwargs):
|
def turn_on(self, transition_time, pipeline, **kwargs):
|
||||||
"""Turn on (or adjust property of) a group."""
|
"""Turn on (or adjust property of) a group."""
|
||||||
|
@ -203,6 +216,11 @@ class LimitlessLEDRGBWGroup(LimitlessLEDGroup):
|
||||||
"""Return the color property."""
|
"""Return the color property."""
|
||||||
return self._color
|
return self._color
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_LIMITLESSLED_RGB
|
||||||
|
|
||||||
@state(True)
|
@state(True)
|
||||||
def turn_on(self, transition_time, pipeline, **kwargs):
|
def turn_on(self, transition_time, pipeline, **kwargs):
|
||||||
"""Turn on (or adjust property of) a group."""
|
"""Turn on (or adjust property of) a group."""
|
||||||
|
|
|
@ -11,7 +11,8 @@ import voluptuous as vol
|
||||||
|
|
||||||
import homeassistant.components.mqtt as mqtt
|
import homeassistant.components.mqtt as mqtt
|
||||||
from homeassistant.components.light import (
|
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.const import CONF_NAME, CONF_OPTIMISTIC, CONF_VALUE_TEMPLATE
|
||||||
from homeassistant.components.mqtt import (
|
from homeassistant.components.mqtt import (
|
||||||
CONF_STATE_TOPIC, CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN)
|
CONF_STATE_TOPIC, CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN)
|
||||||
|
@ -108,6 +109,11 @@ class MqttLight(Light):
|
||||||
topic["brightness_state_topic"] is None)
|
topic["brightness_state_topic"] is None)
|
||||||
self._brightness_scale = brightness_scale
|
self._brightness_scale = brightness_scale
|
||||||
self._state = False
|
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
|
templates = {key: ((lambda value: value) if tpl is None else
|
||||||
partial(render_with_possible_json_value, hass, tpl))
|
partial(render_with_possible_json_value, hass, tpl))
|
||||||
|
@ -188,6 +194,11 @@ class MqttLight(Light):
|
||||||
"""Return true if we do optimistic updates."""
|
"""Return true if we do optimistic updates."""
|
||||||
return self._optimistic
|
return self._optimistic
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return self._supported_features
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
should_update = False
|
should_update = False
|
||||||
|
|
|
@ -12,7 +12,8 @@ import voluptuous as vol
|
||||||
import homeassistant.components.mqtt as mqtt
|
import homeassistant.components.mqtt as mqtt
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ATTR_TRANSITION,
|
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.const import CONF_NAME, CONF_OPTIMISTIC, CONF_PLATFORM
|
||||||
from homeassistant.components.mqtt import (
|
from homeassistant.components.mqtt import (
|
||||||
CONF_STATE_TOPIC, CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN)
|
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_SHORT = "flash_time_short"
|
||||||
CONF_FLASH_TIME_LONG = "flash_time_long"
|
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.
|
# Stealing some of these from the base MQTT configs.
|
||||||
PLATFORM_SCHEMA = vol.Schema({
|
PLATFORM_SCHEMA = vol.Schema({
|
||||||
vol.Required(CONF_PLATFORM): DOMAIN,
|
vol.Required(CONF_PLATFORM): DOMAIN,
|
||||||
|
|
|
@ -9,7 +9,8 @@ import logging
|
||||||
|
|
||||||
from homeassistant.components import mysensors
|
from homeassistant.components import mysensors
|
||||||
from homeassistant.components.light import (ATTR_BRIGHTNESS, ATTR_RGB_COLOR,
|
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.const import STATE_OFF, STATE_ON
|
||||||
from homeassistant.util.color import rgb_hex_to_rgb_list
|
from homeassistant.util.color import rgb_hex_to_rgb_list
|
||||||
|
|
||||||
|
@ -18,6 +19,8 @@ ATTR_RGB_WHITE = 'rgb_white'
|
||||||
ATTR_VALUE = 'value'
|
ATTR_VALUE = 'value'
|
||||||
ATTR_VALUE_TYPE = 'value_type'
|
ATTR_VALUE_TYPE = 'value_type'
|
||||||
|
|
||||||
|
SUPPORT_MYSENSORS = SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the mysensors platform for sensors."""
|
"""Setup the mysensors platform for sensors."""
|
||||||
|
@ -87,6 +90,11 @@ class MySensorsLight(mysensors.MySensorsDeviceEntity, Light):
|
||||||
"""Return true if device is on."""
|
"""Return true if device is on."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_MYSENSORS
|
||||||
|
|
||||||
def _turn_on_light(self):
|
def _turn_on_light(self):
|
||||||
"""Turn on light child device."""
|
"""Turn on light child device."""
|
||||||
set_req = self.gateway.const.SetReq
|
set_req = self.gateway.const.SetReq
|
||||||
|
|
|
@ -15,7 +15,11 @@ from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_COLOR_TEMP,
|
ATTR_COLOR_TEMP,
|
||||||
ATTR_RGB_COLOR,
|
ATTR_RGB_COLOR,
|
||||||
ATTR_TRANSITION
|
ATTR_TRANSITION,
|
||||||
|
SUPPORT_BRIGHTNESS,
|
||||||
|
SUPPORT_COLOR_TEMP,
|
||||||
|
SUPPORT_RGB_COLOR,
|
||||||
|
SUPPORT_TRANSITION,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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_SCANS = timedelta(seconds=10)
|
||||||
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
|
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):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
"""Setup Osram Lightify lights."""
|
"""Setup Osram Lightify lights."""
|
||||||
|
@ -114,6 +121,11 @@ class OsramLightifyLight(Light):
|
||||||
self._light.name(), self._light.on())
|
self._light.name(), self._light.on())
|
||||||
return self._light.on()
|
return self._light.on()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_OSRAMLIGHTIFY
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
brightness = 100
|
brightness = 100
|
||||||
|
|
|
@ -7,7 +7,8 @@ https://home-assistant.io/components/light.rfxtrx/
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import homeassistant.components.rfxtrx as rfxtrx
|
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']
|
DEPENDENCIES = ['rfxtrx']
|
||||||
|
|
||||||
|
@ -15,6 +16,8 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = rfxtrx.DEFAULT_SCHEMA
|
PLATFORM_SCHEMA = rfxtrx.DEFAULT_SCHEMA
|
||||||
|
|
||||||
|
SUPPORT_RFXTRX = SUPPORT_BRIGHTNESS
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
"""Setup the RFXtrx platform."""
|
"""Setup the RFXtrx platform."""
|
||||||
|
@ -48,6 +51,11 @@ class RfxtrxLight(rfxtrx.RfxtrxDevice, Light):
|
||||||
"""Return the brightness of this light between 0..255."""
|
"""Return the brightness of this light between 0..255."""
|
||||||
return self._brightness
|
return self._brightness
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_RFXTRX
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
||||||
|
|
|
@ -7,13 +7,16 @@ https://home-assistant.io/components/light.tellstick/
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import tellstick
|
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,
|
from homeassistant.components.tellstick import (DEFAULT_SIGNAL_REPETITIONS,
|
||||||
ATTR_DISCOVER_DEVICES,
|
ATTR_DISCOVER_DEVICES,
|
||||||
ATTR_DISCOVER_CONFIG)
|
ATTR_DISCOVER_CONFIG)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = vol.Schema({vol.Required("platform"): tellstick.DOMAIN})
|
PLATFORM_SCHEMA = vol.Schema({vol.Required("platform"): tellstick.DOMAIN})
|
||||||
|
|
||||||
|
SUPPORT_TELLSTICK = SUPPORT_BRIGHTNESS
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
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 the brightness of this light between 0..255."""
|
||||||
return self._brightness
|
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):
|
def set_tellstick_state(self, last_command_sent, last_data_sent):
|
||||||
"""Update the internal representation of the switch."""
|
"""Update the internal representation of the switch."""
|
||||||
from tellcore.constants import TELLSTICK_TURNON, TELLSTICK_DIM
|
from tellcore.constants import TELLSTICK_TURNON, TELLSTICK_DIM
|
||||||
|
|
|
@ -6,7 +6,8 @@ https://home-assistant.io/components/light.vera/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.light import ATTR_BRIGHTNESS, Light
|
from homeassistant.components.light import (ATTR_BRIGHTNESS,
|
||||||
|
SUPPORT_BRIGHTNESS, Light)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_OFF, STATE_ON)
|
STATE_OFF, STATE_ON)
|
||||||
from homeassistant.components.vera import (
|
from homeassistant.components.vera import (
|
||||||
|
@ -16,6 +17,8 @@ DEPENDENCIES = ['vera']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
SUPPORT_VERA = SUPPORT_BRIGHTNESS
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
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:
|
if self.vera_device.is_dimmable:
|
||||||
return self.vera_device.get_brightness()
|
return self.vera_device.get_brightness()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_VERA
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
if ATTR_BRIGHTNESS in kwargs and self.vera_device.is_dimmable:
|
if ATTR_BRIGHTNESS in kwargs and self.vera_device.is_dimmable:
|
||||||
|
|
|
@ -11,7 +11,8 @@ import homeassistant.util as util
|
||||||
import homeassistant.util.color as color_util
|
import homeassistant.util.color as color_util
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
Light, ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, ATTR_TRANSITION,
|
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']
|
DEPENDENCIES = ['wemo']
|
||||||
|
|
||||||
|
@ -20,6 +21,9 @@ MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
"""Setup WeMo bridges and register connected lights."""
|
"""Setup WeMo bridges and register connected lights."""
|
||||||
|
@ -96,6 +100,11 @@ class WemoLight(Light):
|
||||||
"""True if device is on."""
|
"""True if device is on."""
|
||||||
return self.device.state['onoff'] != 0
|
return self.device.state['onoff'] != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_WEMO
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
transitiontime = int(kwargs.get(ATTR_TRANSITION, 0))
|
transitiontime = int(kwargs.get(ATTR_TRANSITION, 0))
|
||||||
|
|
|
@ -7,7 +7,8 @@ https://home-assistant.io/components/light.wink/
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.light import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, \
|
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.components.wink import WinkDevice
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
from homeassistant.util import color as color_util
|
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']
|
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):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
"""Setup Wink lights."""
|
"""Setup Wink lights."""
|
||||||
|
@ -68,6 +71,11 @@ class WinkLight(WinkDevice, Light):
|
||||||
return color_util.color_temperature_kelvin_to_mired(
|
return color_util.color_temperature_kelvin_to_mired(
|
||||||
self.wink.color_temperature_kelvin())
|
self.wink.color_temperature_kelvin())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_WINK
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the switch on."""
|
"""Turn the switch on."""
|
||||||
|
|
|
@ -6,10 +6,13 @@ https://home-assistant.io/components/light.x10/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from subprocess import check_output, CalledProcessError, STDOUT
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
SUPPORT_X10 = SUPPORT_BRIGHTNESS
|
||||||
|
|
||||||
|
|
||||||
def x10_command(command):
|
def x10_command(command):
|
||||||
"""Execute X10 command and check output."""
|
"""Execute X10 command and check output."""
|
||||||
|
@ -64,6 +67,11 @@ class X10Light(Light):
|
||||||
"""Return true if light is on."""
|
"""Return true if light is on."""
|
||||||
return self._is_on
|
return self._is_on
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_X10
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Instruct the light to turn on."""
|
"""Instruct the light to turn on."""
|
||||||
x10_command("on " + self._id)
|
x10_command("on " + self._id)
|
||||||
|
|
|
@ -10,7 +10,8 @@ import logging
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error
|
||||||
from threading import Timer
|
from threading import Timer
|
||||||
from homeassistant.components.light import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, \
|
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.components import zwave
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON
|
from homeassistant.const import STATE_OFF, STATE_ON
|
||||||
from homeassistant.util.color import HASS_COLOR_MAX, HASS_COLOR_MIN, \
|
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_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
|
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):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Find and add Z-Wave lights."""
|
"""Find and add Z-Wave lights."""
|
||||||
|
@ -137,6 +140,11 @@ class ZwaveDimmer(zwave.ZWaveDeviceEntity, Light):
|
||||||
"""Return true if device is on."""
|
"""Return true if device is on."""
|
||||||
return self._state == STATE_ON
|
return self._state == STATE_ON
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_ZWAVE
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
|
|
|
@ -10,7 +10,8 @@ import voluptuous as vol
|
||||||
from homeassistant.const import (EVENT_HOMEASSISTANT_START,
|
from homeassistant.const import (EVENT_HOMEASSISTANT_START,
|
||||||
EVENT_HOMEASSISTANT_STOP)
|
EVENT_HOMEASSISTANT_STOP)
|
||||||
from homeassistant.helpers.discovery import load_platform
|
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
|
from homeassistant.components.switch import SwitchDevice
|
||||||
|
|
||||||
DOMAIN = 'qwikswitch'
|
DOMAIN = 'qwikswitch'
|
||||||
|
@ -29,6 +30,8 @@ CONFIG_SCHEMA = vol.Schema({
|
||||||
|
|
||||||
QSUSB = {}
|
QSUSB = {}
|
||||||
|
|
||||||
|
SUPPORT_QWIKSWITCH = SUPPORT_BRIGHTNESS
|
||||||
|
|
||||||
|
|
||||||
class QSToggleEntity(object):
|
class QSToggleEntity(object):
|
||||||
"""Representation of a Qwikswitch Entity.
|
"""Representation of a Qwikswitch Entity.
|
||||||
|
@ -108,7 +111,10 @@ class QSSwitch(QSToggleEntity, SwitchDevice):
|
||||||
class QSLight(QSToggleEntity, Light):
|
class QSLight(QSToggleEntity, Light):
|
||||||
"""Light based on a Qwikswitch relay/dimmer module."""
|
"""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
|
# pylint: disable=too-many-locals
|
||||||
|
|
Loading…
Reference in New Issue