Renamed to color_temp, removed capabilities (not needed afterall)
This commit is contained in:
parent
805aecd6f9
commit
6bad702db4
4 changed files with 25 additions and 44 deletions
|
@ -43,7 +43,7 @@ Supports following parameters:
|
||||||
A list containing three integers representing the xy color you want the
|
A list containing three integers representing the xy color you want the
|
||||||
light to be.
|
light to be.
|
||||||
|
|
||||||
- ct_color
|
- color_temp
|
||||||
An INT in mireds represending the color temperature you want the light to be
|
An INT in mireds represending the color temperature you want the light to be
|
||||||
|
|
||||||
- brightness
|
- brightness
|
||||||
|
@ -80,7 +80,7 @@ ATTR_TRANSITION = "transition"
|
||||||
# lists holding color values
|
# lists holding color values
|
||||||
ATTR_RGB_COLOR = "rgb_color"
|
ATTR_RGB_COLOR = "rgb_color"
|
||||||
ATTR_XY_COLOR = "xy_color"
|
ATTR_XY_COLOR = "xy_color"
|
||||||
ATTR_CT_COLOR = "ct_color"
|
ATTR_COLOR_TEMP = "color_temp"
|
||||||
|
|
||||||
# int with value 0 .. 255 representing brightness of the light
|
# int with value 0 .. 255 representing brightness of the light
|
||||||
ATTR_BRIGHTNESS = "brightness"
|
ATTR_BRIGHTNESS = "brightness"
|
||||||
|
@ -109,7 +109,7 @@ DISCOVERY_PLATFORMS = {
|
||||||
PROP_TO_ATTR = {
|
PROP_TO_ATTR = {
|
||||||
'brightness': ATTR_BRIGHTNESS,
|
'brightness': ATTR_BRIGHTNESS,
|
||||||
'color_xy': ATTR_XY_COLOR,
|
'color_xy': ATTR_XY_COLOR,
|
||||||
'color_ct': ATTR_CT_COLOR,
|
'color_temp': ATTR_COLOR_TEMP,
|
||||||
}
|
}
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -124,7 +124,7 @@ def is_on(hass, entity_id=None):
|
||||||
|
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
def turn_on(hass, entity_id=None, transition=None, brightness=None,
|
def turn_on(hass, entity_id=None, transition=None, brightness=None,
|
||||||
rgb_color=None, xy_color=None, ct_color=None, profile=None,
|
rgb_color=None, xy_color=None, color_temp=None, profile=None,
|
||||||
flash=None, effect=None):
|
flash=None, effect=None):
|
||||||
""" Turns all or specified light on. """
|
""" Turns all or specified light on. """
|
||||||
data = {
|
data = {
|
||||||
|
@ -135,7 +135,7 @@ def turn_on(hass, entity_id=None, transition=None, brightness=None,
|
||||||
(ATTR_BRIGHTNESS, brightness),
|
(ATTR_BRIGHTNESS, brightness),
|
||||||
(ATTR_RGB_COLOR, rgb_color),
|
(ATTR_RGB_COLOR, rgb_color),
|
||||||
(ATTR_XY_COLOR, xy_color),
|
(ATTR_XY_COLOR, xy_color),
|
||||||
(ATTR_CT_COLOR, ct_color),
|
(ATTR_COLOR_TEMP, color_temp),
|
||||||
(ATTR_FLASH, flash),
|
(ATTR_FLASH, flash),
|
||||||
(ATTR_EFFECT, effect),
|
(ATTR_EFFECT, effect),
|
||||||
] if value is not None
|
] if value is not None
|
||||||
|
@ -246,15 +246,15 @@ def setup(hass, config):
|
||||||
# ValueError if value could not be converted to float
|
# ValueError if value could not be converted to float
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if ATTR_CT_COLOR in dat:
|
if ATTR_COLOR_TEMP in dat:
|
||||||
# ct_color should be an int of mirads value
|
# color_temp should be an int of mirads value
|
||||||
ctcolor = dat.get(ATTR_CT_COLOR)
|
colortemp = dat.get(ATTR_COLOR_TEMP)
|
||||||
|
|
||||||
# Without this check, a ctcolor with value '99' would work
|
# Without this check, a ctcolor with value '99' would work
|
||||||
# These values are based on Philips Hue, may need ajustment later
|
# These values are based on Philips Hue, may need ajustment later
|
||||||
if isinstance(ctcolor, int):
|
if isinstance(colortemp, int):
|
||||||
if 154 <= ctcolor <= 500:
|
if 154 <= colortemp <= 500:
|
||||||
params[ATTR_CT_COLOR] = ctcolor
|
params[ATTR_COLOR_TEMP] = colortemp
|
||||||
|
|
||||||
if ATTR_RGB_COLOR in dat:
|
if ATTR_RGB_COLOR in dat:
|
||||||
try:
|
try:
|
||||||
|
@ -318,7 +318,7 @@ class Light(ToggleEntity):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_ct(self):
|
def color_temp(self):
|
||||||
""" CT color value in mirads. """
|
""" CT color value in mirads. """
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ Demo platform that implements lights.
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
Light, ATTR_BRIGHTNESS, ATTR_XY_COLOR, ATTR_CT_COLOR)
|
Light, ATTR_BRIGHTNESS, ATTR_XY_COLOR, ATTR_COLOR_TEMP)
|
||||||
|
|
||||||
|
|
||||||
LIGHT_COLORS = [
|
LIGHT_COLORS = [
|
||||||
|
@ -59,7 +59,7 @@ class DemoLight(Light):
|
||||||
return self._xy
|
return self._xy
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_ct(self):
|
def color_temp(self):
|
||||||
""" CT color temperature. """
|
""" CT color temperature. """
|
||||||
return self._ct
|
return self._ct
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ class DemoLight(Light):
|
||||||
if ATTR_XY_COLOR in kwargs:
|
if ATTR_XY_COLOR in kwargs:
|
||||||
self._xy = kwargs[ATTR_XY_COLOR]
|
self._xy = kwargs[ATTR_XY_COLOR]
|
||||||
|
|
||||||
if ATTR_CT_COLOR in kwargs:
|
if ATTR_COLOR_TEMP in kwargs:
|
||||||
self._ct = kwargs[ATTR_CT_COLOR]
|
self._ct = kwargs[ATTR_COLOR_TEMP]
|
||||||
|
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
self._brightness = kwargs[ATTR_BRIGHTNESS]
|
self._brightness = kwargs[ATTR_BRIGHTNESS]
|
||||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.loader import get_component
|
||||||
import homeassistant.util as util
|
import homeassistant.util as util
|
||||||
from homeassistant.const import CONF_HOST, DEVICE_DEFAULT_NAME
|
from homeassistant.const import CONF_HOST, DEVICE_DEFAULT_NAME
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
Light, ATTR_BRIGHTNESS, ATTR_XY_COLOR, ATTR_CT_COLOR,
|
Light, ATTR_BRIGHTNESS, ATTR_XY_COLOR, ATTR_COLOR_TEMP,
|
||||||
ATTR_TRANSITION, ATTR_FLASH, FLASH_LONG, FLASH_SHORT,
|
ATTR_TRANSITION, ATTR_FLASH, FLASH_LONG, FLASH_SHORT,
|
||||||
ATTR_EFFECT, EFFECT_COLORLOOP)
|
ATTR_EFFECT, EFFECT_COLORLOOP)
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ def request_configuration(host, hass, add_devices_callback):
|
||||||
_CONFIGURING[host], "Failed to register, please try again.")
|
_CONFIGURING[host], "Failed to register, please try again.")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
# pylint: disable=unused-argument
|
||||||
def hue_configuration_callback(data):
|
def hue_configuration_callback(data):
|
||||||
""" Actions to do when our configuration callback is called. """
|
""" Actions to do when our configuration callback is called. """
|
||||||
setup_bridge(host, hass, add_devices_callback)
|
setup_bridge(host, hass, add_devices_callback)
|
||||||
|
@ -147,16 +147,6 @@ class HueLight(Light):
|
||||||
self.bridge = bridge
|
self.bridge = bridge
|
||||||
self.update_lights = update_lights
|
self.update_lights = update_lights
|
||||||
|
|
||||||
# Hue can control multiple type of lights
|
|
||||||
capability_map = {
|
|
||||||
'Dimmable light': ['bri'],
|
|
||||||
'Dimmable plug-in unit': ['bri'],
|
|
||||||
'Color light': ['bri', 'xy'],
|
|
||||||
'Extended color light': ['bri', 'xy', 'ct'],
|
|
||||||
'unknown': []}
|
|
||||||
self.capabilities = capability_map.get(
|
|
||||||
self.info['type'], 'unknown')
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
""" Returns the id of this Hue light """
|
""" Returns the id of this Hue light """
|
||||||
|
@ -171,26 +161,17 @@ class HueLight(Light):
|
||||||
@property
|
@property
|
||||||
def brightness(self):
|
def brightness(self):
|
||||||
""" Brightness of this light between 0..255. """
|
""" Brightness of this light between 0..255. """
|
||||||
if 'bri' in self.capabilities:
|
return self.info['state']['bri']
|
||||||
return self.info['state']['bri']
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_xy(self):
|
def color_xy(self):
|
||||||
""" XY color value. """
|
""" XY color value. """
|
||||||
if 'xy' in self.capabilities:
|
return self.info['state'].get('xy')
|
||||||
return self.info['state'].get('xy')
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_ct(self):
|
def color_temp(self):
|
||||||
""" CT color value. """
|
""" CT color value. """
|
||||||
if 'ct' in self.capabilities:
|
return self.info['state'].get('ct')
|
||||||
return self.info['state'].get('ct')
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
@ -214,8 +195,8 @@ class HueLight(Light):
|
||||||
if ATTR_XY_COLOR in kwargs:
|
if ATTR_XY_COLOR in kwargs:
|
||||||
command['xy'] = kwargs[ATTR_XY_COLOR]
|
command['xy'] = kwargs[ATTR_XY_COLOR]
|
||||||
|
|
||||||
if ATTR_CT_COLOR in kwargs:
|
if ATTR_COLOR_TEMP in kwargs:
|
||||||
command['ct'] = kwargs[ATTR_CT_COLOR]
|
command['ct'] = kwargs[ATTR_COLOR_TEMP]
|
||||||
|
|
||||||
flash = kwargs.get(ATTR_FLASH)
|
flash = kwargs.get(ATTR_FLASH)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ turn_on:
|
||||||
description: Color for the light in XY-format
|
description: Color for the light in XY-format
|
||||||
example: '[0.52, 0.43]'
|
example: '[0.52, 0.43]'
|
||||||
|
|
||||||
ct_color:
|
color_temp:
|
||||||
description: Color temperature for the light in mireds (154-500)
|
description: Color temperature for the light in mireds (154-500)
|
||||||
example: '250'
|
example: '250'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue