diff --git a/homeassistant/components/mqtt/discovery.py b/homeassistant/components/mqtt/discovery.py index 86cce757449..c3ff0f9dce5 100644 --- a/homeassistant/components/mqtt/discovery.py +++ b/homeassistant/components/mqtt/discovery.py @@ -19,12 +19,13 @@ _LOGGER = logging.getLogger(__name__) TOPIC_MATCHER = re.compile( r'(?P\w+)/(?P\w+)/(?P\w+)/config') -SUPPORTED_COMPONENTS = ['binary_sensor', 'light', 'sensor'] +SUPPORTED_COMPONENTS = ['binary_sensor', 'light', 'sensor', 'switch'] ALLOWED_PLATFORMS = { 'binary_sensor': ['mqtt'], 'light': ['mqtt', 'mqtt_json', 'mqtt_template'], - 'sensor': ['mqtt'] + 'sensor': ['mqtt'], + 'switch': ['mqtt'], } diff --git a/homeassistant/components/switch/mqtt.py b/homeassistant/components/switch/mqtt.py index d94815a1d2e..391df2ad67e 100644 --- a/homeassistant/components/switch/mqtt.py +++ b/homeassistant/components/switch/mqtt.py @@ -38,7 +38,10 @@ PLATFORM_SCHEMA = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend({ @asyncio.coroutine 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) if value_template is not None: value_template.hass = hass