mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Migrate to voluptuous (#2927)
This commit is contained in:
parent
2b4f0cb5a1
commit
a43ea81d8e
@ -7,29 +7,31 @@ https://home-assistant.io/components/logentries/
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import requests
|
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 state as state_helper
|
||||||
from homeassistant.helpers import validate_config
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = "logentries"
|
DOMAIN = 'logentries'
|
||||||
DEPENDENCIES = []
|
|
||||||
|
|
||||||
DEFAULT_HOST = 'https://webhook.logentries.com/noformat/logs/'
|
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):
|
def setup(hass, config):
|
||||||
"""Setup the Logentries component."""
|
"""Setup the Logentries component."""
|
||||||
if not validate_config(config, {DOMAIN: ['token']}, _LOGGER):
|
|
||||||
_LOGGER.error("Logentries token not present")
|
|
||||||
return False
|
|
||||||
conf = config[DOMAIN]
|
conf = config[DOMAIN]
|
||||||
token = util.convert(conf.get(CONF_TOKEN), str)
|
token = conf.get(CONF_TOKEN)
|
||||||
le_wh = DEFAULT_HOST + token
|
le_wh = '{}{}'.format(DEFAULT_HOST, token)
|
||||||
|
|
||||||
def logentries_event_listener(event):
|
def logentries_event_listener(event):
|
||||||
"""Listen for new messages on the bus and sends them to Logentries."""
|
"""Listen for new messages on the bus and sends them to Logentries."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user