Skip to content

Commit

Permalink
Add switch to MQTT discovery (home-assistant#6733)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabaff authored Mar 26, 2017
1 parent f5d4f85 commit 22b28d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions homeassistant/components/mqtt/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
TOPIC_MATCHER = re.compile(
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 = {
'binary_sensor': ['mqtt'],
'light': ['mqtt', 'mqtt_json', 'mqtt_template'],
'sensor': ['mqtt']
'sensor': ['mqtt'],
'switch': ['mqtt'],
}


Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/switch/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@

@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
Expand Down

0 comments on commit 22b28d8

Please sign in to comment.