mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Add switch to MQTT discovery (#6733)
This commit is contained in:
parent
f5d4f853ba
commit
22b28d85db
@ -19,12 +19,13 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
TOPIC_MATCHER = re.compile(
|
TOPIC_MATCHER = re.compile(
|
||||||
r'(?P<prefix_topic>\w+)/(?P<component>\w+)/(?P<object_id>\w+)/config')
|
r'(?P<prefix_topic>\w+)/(?P<component>\w+)/(?P<object_id>\w+)/config')
|
||||||
|
|
||||||
SUPPORTED_COMPONENTS = ['binary_sensor', 'light', 'sensor']
|
SUPPORTED_COMPONENTS = ['binary_sensor', 'light', 'sensor', 'switch']
|
||||||
|
|
||||||
ALLOWED_PLATFORMS = {
|
ALLOWED_PLATFORMS = {
|
||||||
'binary_sensor': ['mqtt'],
|
'binary_sensor': ['mqtt'],
|
||||||
'light': ['mqtt', 'mqtt_json', 'mqtt_template'],
|
'light': ['mqtt', 'mqtt_json', 'mqtt_template'],
|
||||||
'sensor': ['mqtt']
|
'sensor': ['mqtt'],
|
||||||
|
'switch': ['mqtt'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,10 @@ PLATFORM_SCHEMA = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend({
|
|||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||||
"""Setup the MQTT switch."""
|
"""Set up the MQTT switch."""
|
||||||
|
if discovery_info is not None:
|
||||||
|
config = PLATFORM_SCHEMA(discovery_info)
|
||||||
|
|
||||||
value_template = config.get(CONF_VALUE_TEMPLATE)
|
value_template = config.get(CONF_VALUE_TEMPLATE)
|
||||||
if value_template is not None:
|
if value_template is not None:
|
||||||
value_template.hass = hass
|
value_template.hass = hass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user