Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion homeassistant/components/splunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import voluptuous as vol

from homeassistant.const import (
CONF_HOST, CONF_PORT, CONF_SSL, CONF_TOKEN, EVENT_STATE_CHANGED)
CONF_NAME, CONF_HOST, CONF_PORT, CONF_SSL, CONF_TOKEN, EVENT_STATE_CHANGED)
from homeassistant.helpers import state as state_helper
import homeassistant.helpers.config_validation as cv

Expand All @@ -22,13 +22,15 @@
DEFAULT_HOST = 'localhost'
DEFAULT_PORT = 8088
DEFAULT_SSL = False
DEFAULT_NAME = 'HASS'

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_TOKEN): cv.string,
vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
vol.Optional(CONF_SSL, default=False): cv.boolean,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
}),
}, extra=vol.ALLOW_EXTRA)

Expand All @@ -40,6 +42,7 @@ def setup(hass, config):
port = conf.get(CONF_PORT)
token = conf.get(CONF_TOKEN)
use_ssl = conf.get(CONF_SSL)
name = conf.get(CONF_NAME)

if use_ssl:
uri_scheme = 'https://'
Expand Down Expand Up @@ -69,6 +72,7 @@ def splunk_event_listener(event):
'attributes': dict(state.attributes),
'time': str(event.time_fired),
'value': _state,
'host': name,
}
]

Expand Down
2 changes: 2 additions & 0 deletions tests/components/test_splunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_setup_config_full(self):
'port': 123,
'token': 'secret',
'ssl': 'False',
'name': 'hostname',
}
}

Expand Down Expand Up @@ -96,6 +97,7 @@ def test_event_listener(self, mock_dump, mock_requests):
'attributes': {},
'time': '12345',
'value': out,
'host': 'HASS',
}]

payload = {'host': 'http://host:8088/services/collector/event',
Expand Down