parent
1cace5782c
commit
fb0232429e
3 changed files with 38 additions and 44 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue