mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Added support for colored KNX lights (#12411)
This commit is contained in:
parent
7e2e82d956
commit
96bd153c80
@ -14,7 +14,7 @@ from homeassistant.helpers import discovery
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.script import Script
|
from homeassistant.helpers.script import Script
|
||||||
|
|
||||||
REQUIREMENTS = ['xknx==0.7.18']
|
REQUIREMENTS = ['xknx==0.8.3']
|
||||||
|
|
||||||
DOMAIN = "knx"
|
DOMAIN = "knx"
|
||||||
DATA_KNX = "data_knx"
|
DATA_KNX = "data_knx"
|
||||||
@ -216,7 +216,7 @@ class KNXModule(object):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def service_send_to_knx_bus(self, call):
|
def service_send_to_knx_bus(self, call):
|
||||||
"""Service for sending an arbitrary KNX message to the KNX bus."""
|
"""Service for sending an arbitrary KNX message to the KNX bus."""
|
||||||
from xknx.knx import Telegram, Address, DPTBinary, DPTArray
|
from xknx.knx import Telegram, GroupAddress, DPTBinary, DPTArray
|
||||||
attr_payload = call.data.get(SERVICE_KNX_ATTR_PAYLOAD)
|
attr_payload = call.data.get(SERVICE_KNX_ATTR_PAYLOAD)
|
||||||
attr_address = call.data.get(SERVICE_KNX_ATTR_ADDRESS)
|
attr_address = call.data.get(SERVICE_KNX_ATTR_ADDRESS)
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ class KNXModule(object):
|
|||||||
return DPTBinary(attr_payload)
|
return DPTBinary(attr_payload)
|
||||||
return DPTArray(attr_payload)
|
return DPTArray(attr_payload)
|
||||||
payload = calculate_payload(attr_payload)
|
payload = calculate_payload(attr_payload)
|
||||||
address = Address(attr_address)
|
address = GroupAddress(attr_address)
|
||||||
|
|
||||||
telegram = Telegram()
|
telegram = Telegram()
|
||||||
telegram.payload = payload
|
telegram.payload = payload
|
||||||
|
@ -10,7 +10,8 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.knx import ATTR_DISCOVER_DEVICES, DATA_KNX
|
from homeassistant.components.knx import ATTR_DISCOVER_DEVICES, DATA_KNX
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS, PLATFORM_SCHEMA, SUPPORT_BRIGHTNESS, Light)
|
ATTR_BRIGHTNESS, ATTR_RGB_COLOR, PLATFORM_SCHEMA, SUPPORT_BRIGHTNESS,
|
||||||
|
SUPPORT_RGB_COLOR, Light)
|
||||||
from homeassistant.const import CONF_NAME
|
from homeassistant.const import CONF_NAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -19,6 +20,8 @@ CONF_ADDRESS = 'address'
|
|||||||
CONF_STATE_ADDRESS = 'state_address'
|
CONF_STATE_ADDRESS = 'state_address'
|
||||||
CONF_BRIGHTNESS_ADDRESS = 'brightness_address'
|
CONF_BRIGHTNESS_ADDRESS = 'brightness_address'
|
||||||
CONF_BRIGHTNESS_STATE_ADDRESS = 'brightness_state_address'
|
CONF_BRIGHTNESS_STATE_ADDRESS = 'brightness_state_address'
|
||||||
|
CONF_COLOR_ADDRESS = 'color_address'
|
||||||
|
CONF_COLOR_STATE_ADDRESS = 'color_state_address'
|
||||||
|
|
||||||
DEFAULT_NAME = 'KNX Light'
|
DEFAULT_NAME = 'KNX Light'
|
||||||
DEPENDENCIES = ['knx']
|
DEPENDENCIES = ['knx']
|
||||||
@ -29,6 +32,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||||||
vol.Optional(CONF_STATE_ADDRESS): cv.string,
|
vol.Optional(CONF_STATE_ADDRESS): cv.string,
|
||||||
vol.Optional(CONF_BRIGHTNESS_ADDRESS): cv.string,
|
vol.Optional(CONF_BRIGHTNESS_ADDRESS): cv.string,
|
||||||
vol.Optional(CONF_BRIGHTNESS_STATE_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,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -66,7 +71,9 @@ def async_add_devices_config(hass, config, async_add_devices):
|
|||||||
group_address_switch_state=config.get(CONF_STATE_ADDRESS),
|
group_address_switch_state=config.get(CONF_STATE_ADDRESS),
|
||||||
group_address_brightness=config.get(CONF_BRIGHTNESS_ADDRESS),
|
group_address_brightness=config.get(CONF_BRIGHTNESS_ADDRESS),
|
||||||
group_address_brightness_state=config.get(
|
group_address_brightness_state=config.get(
|
||||||
CONF_BRIGHTNESS_STATE_ADDRESS))
|
CONF_BRIGHTNESS_STATE_ADDRESS),
|
||||||
|
group_address_color=config.get(CONF_COLOR_ADDRESS),
|
||||||
|
group_address_color_state=config.get(CONF_COLOR_STATE_ADDRESS))
|
||||||
hass.data[DATA_KNX].xknx.devices.add(light)
|
hass.data[DATA_KNX].xknx.devices.add(light)
|
||||||
async_add_devices([KNXLight(hass, light)])
|
async_add_devices([KNXLight(hass, light)])
|
||||||
|
|
||||||
@ -120,6 +127,8 @@ class KNXLight(Light):
|
|||||||
@property
|
@property
|
||||||
def rgb_color(self):
|
def rgb_color(self):
|
||||||
"""Return the RBG color value."""
|
"""Return the RBG color value."""
|
||||||
|
if self.device.supports_color:
|
||||||
|
return self.device.current_color()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -153,6 +162,8 @@ class KNXLight(Light):
|
|||||||
flags = 0
|
flags = 0
|
||||||
if self.device.supports_dimming:
|
if self.device.supports_dimming:
|
||||||
flags |= SUPPORT_BRIGHTNESS
|
flags |= SUPPORT_BRIGHTNESS
|
||||||
|
if self.device.supports_color:
|
||||||
|
flags |= SUPPORT_RGB_COLOR
|
||||||
return flags
|
return flags
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
@ -160,6 +171,8 @@ class KNXLight(Light):
|
|||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
if ATTR_BRIGHTNESS in kwargs and self.device.supports_dimming:
|
if ATTR_BRIGHTNESS in kwargs and self.device.supports_dimming:
|
||||||
yield from self.device.set_brightness(int(kwargs[ATTR_BRIGHTNESS]))
|
yield from self.device.set_brightness(int(kwargs[ATTR_BRIGHTNESS]))
|
||||||
|
elif ATTR_RGB_COLOR in kwargs:
|
||||||
|
yield from self.device.set_color(kwargs[ATTR_RGB_COLOR])
|
||||||
else:
|
else:
|
||||||
yield from self.device.set_on()
|
yield from self.device.set_on()
|
||||||
|
|
||||||
|
@ -1239,7 +1239,7 @@ xbee-helper==0.0.7
|
|||||||
xboxapi==0.1.1
|
xboxapi==0.1.1
|
||||||
|
|
||||||
# homeassistant.components.knx
|
# homeassistant.components.knx
|
||||||
xknx==0.7.18
|
xknx==0.8.3
|
||||||
|
|
||||||
# homeassistant.components.media_player.bluesound
|
# homeassistant.components.media_player.bluesound
|
||||||
# homeassistant.components.sensor.startca
|
# homeassistant.components.sensor.startca
|
||||||
|
Loading…
x
Reference in New Issue
Block a user