mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Simplify MQTT light code
This commit is contained in:
parent
1c08923ffc
commit
177590fd65
@ -24,12 +24,6 @@ DEFAULT_OPTIMISTIC = False
|
|||||||
|
|
||||||
DEPENDENCIES = ['mqtt']
|
DEPENDENCIES = ['mqtt']
|
||||||
|
|
||||||
CONF_TOPICS = [typ + topic
|
|
||||||
for typ in ('', 'brightness_', 'rgb_')
|
|
||||||
for topic in ('state_topic', 'command_topic')]
|
|
||||||
CONF_VALUE_TEMPLATES = [typ + '_value_template'
|
|
||||||
for typ in ('state', 'brightness', 'rgb')]
|
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
""" Add MQTT Light. """
|
""" Add MQTT Light. """
|
||||||
@ -41,7 +35,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
add_devices_callback([MqttLight(
|
add_devices_callback([MqttLight(
|
||||||
hass,
|
hass,
|
||||||
config.get('name', DEFAULT_NAME),
|
config.get('name', DEFAULT_NAME),
|
||||||
{key: config.get(key) for key in CONF_TOPICS},
|
{key: config.get(key) for key in
|
||||||
|
(typ + topic
|
||||||
|
for typ in ('', 'brightness_', 'rgb_')
|
||||||
|
for topic in ('state_topic', 'command_topic'))},
|
||||||
{key: config.get(key + '_value_template')
|
{key: config.get(key + '_value_template')
|
||||||
for key in ('state', 'brightness', 'rgb')},
|
for key in ('state', 'brightness', 'rgb')},
|
||||||
config.get('qos', DEFAULT_QOS),
|
config.get('qos', DEFAULT_QOS),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user