mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add support for alarm_control_panel to MQTT Discovery. (#15689)
This commit is contained in:
parent
b2f4bbf93b
commit
cd6544d32a
@ -49,6 +49,9 @@ PLATFORM_SCHEMA = mqtt.MQTT_BASE_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):
|
||||||
"""Set up the MQTT Alarm Control Panel platform."""
|
"""Set up the MQTT Alarm Control Panel platform."""
|
||||||
|
if discovery_info is not None:
|
||||||
|
config = PLATFORM_SCHEMA(discovery_info)
|
||||||
|
|
||||||
async_add_devices([MqttAlarm(
|
async_add_devices([MqttAlarm(
|
||||||
config.get(CONF_NAME),
|
config.get(CONF_NAME),
|
||||||
config.get(CONF_STATE_TOPIC),
|
config.get(CONF_STATE_TOPIC),
|
||||||
|
@ -21,7 +21,8 @@ TOPIC_MATCHER = re.compile(
|
|||||||
|
|
||||||
SUPPORTED_COMPONENTS = [
|
SUPPORTED_COMPONENTS = [
|
||||||
'binary_sensor', 'camera', 'cover', 'fan',
|
'binary_sensor', 'camera', 'cover', 'fan',
|
||||||
'light', 'sensor', 'switch', 'lock', 'climate']
|
'light', 'sensor', 'switch', 'lock', 'climate',
|
||||||
|
'alarm_control_panel']
|
||||||
|
|
||||||
ALLOWED_PLATFORMS = {
|
ALLOWED_PLATFORMS = {
|
||||||
'binary_sensor': ['mqtt'],
|
'binary_sensor': ['mqtt'],
|
||||||
@ -33,6 +34,7 @@ ALLOWED_PLATFORMS = {
|
|||||||
'sensor': ['mqtt'],
|
'sensor': ['mqtt'],
|
||||||
'switch': ['mqtt'],
|
'switch': ['mqtt'],
|
||||||
'climate': ['mqtt'],
|
'climate': ['mqtt'],
|
||||||
|
'alarm_control_panel': ['mqtt'],
|
||||||
}
|
}
|
||||||
|
|
||||||
ALREADY_DISCOVERED = 'mqtt_discovered_components'
|
ALREADY_DISCOVERED = 'mqtt_discovered_components'
|
||||||
|
@ -124,6 +124,28 @@ def test_discover_climate(hass, mqtt_mock, caplog):
|
|||||||
assert ('climate', 'bla') in hass.data[ALREADY_DISCOVERED]
|
assert ('climate', 'bla') in hass.data[ALREADY_DISCOVERED]
|
||||||
|
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def test_discover_alarm_control_panel(hass, mqtt_mock, caplog):
|
||||||
|
"""Test discovering an MQTT alarm control panel component."""
|
||||||
|
yield from async_start(hass, 'homeassistant', {})
|
||||||
|
|
||||||
|
data = (
|
||||||
|
'{ "name": "AlarmControlPanelTest",'
|
||||||
|
' "state_topic": "test_topic",'
|
||||||
|
' "command_topic": "test_topic" }'
|
||||||
|
)
|
||||||
|
|
||||||
|
async_fire_mqtt_message(
|
||||||
|
hass, 'homeassistant/alarm_control_panel/bla/config', data)
|
||||||
|
yield from hass.async_block_till_done()
|
||||||
|
|
||||||
|
state = hass.states.get('alarm_control_panel.AlarmControlPanelTest')
|
||||||
|
|
||||||
|
assert state is not None
|
||||||
|
assert state.name == 'AlarmControlPanelTest'
|
||||||
|
assert ('alarm_control_panel', 'bla') in hass.data[ALREADY_DISCOVERED]
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def test_discovery_incl_nodeid(hass, mqtt_mock, caplog):
|
def test_discovery_incl_nodeid(hass, mqtt_mock, caplog):
|
||||||
"""Test sending in correct JSON with optional node_id included."""
|
"""Test sending in correct JSON with optional node_id included."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user