Migrate to voluptuous (#2927)

This commit is contained in:
Fabian Affolter 2016-08-24 02:27:54 +02:00 committed by Paulus Schoutsen
parent 2b4f0cb5a1
commit a43ea81d8e

View File

@ -7,29 +7,31 @@ https://home-assistant.io/components/logentries/
import json
import logging
import requests
import homeassistant.util as util
from homeassistant.const import EVENT_STATE_CHANGED
import voluptuous as vol
from homeassistant.const import (CONF_TOKEN, EVENT_STATE_CHANGED)
from homeassistant.helpers import state as state_helper
from homeassistant.helpers import validate_config
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
DOMAIN = "logentries"
DEPENDENCIES = []
DOMAIN = 'logentries'
DEFAULT_HOST = 'https://webhook.logentries.com/noformat/logs/'
CONF_TOKEN = 'token'
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_TOKEN): cv.string,
}),
}, extra=vol.ALLOW_EXTRA)
def setup(hass, config):
"""Setup the Logentries component."""
if not validate_config(config, {DOMAIN: ['token']}, _LOGGER):
_LOGGER.error("Logentries token not present")
return False
conf = config[DOMAIN]
token = util.convert(conf.get(CONF_TOKEN), str)
le_wh = DEFAULT_HOST + token
token = conf.get(CONF_TOKEN)
le_wh = '{}{}'.format(DEFAULT_HOST, token)
def logentries_event_listener(event):
"""Listen for new messages on the bus and sends them to Logentries."""