Use constants and update ordering (#3268)

🐬
This commit is contained in:
Fabian Affolter 2016-09-09 02:32:32 +02:00 committed by Teagan Glenn
parent 1cace5782c
commit fb0232429e
3 changed files with 38 additions and 44 deletions

View file

@ -7,13 +7,12 @@ at https://home-assistant.io/components/automation/#mqtt-trigger
import voluptuous as vol
import homeassistant.components.mqtt as mqtt
from homeassistant.const import CONF_PLATFORM
from homeassistant.const import (CONF_PLATFORM, CONF_PAYLOAD)
import homeassistant.helpers.config_validation as cv
DEPENDENCIES = ['mqtt']
CONF_TOPIC = 'topic'
CONF_PAYLOAD = 'payload'
TRIGGER_SCHEMA = vol.Schema({
vol.Required(CONF_PLATFORM): mqtt.DOMAIN,
@ -24,7 +23,7 @@ TRIGGER_SCHEMA = vol.Schema({
def trigger(hass, config, action):
"""Listen for state changes based on configuration."""
topic = config[CONF_TOPIC]
topic = config.get(CONF_TOPIC)
payload = config.get(CONF_PAYLOAD)
def mqtt_automation_listener(msg_topic, msg_payload, qos):