Skip to content
Snippets Groups Projects
Commit 0d4f681a authored by Fabian Affolter's avatar Fabian Affolter
Browse files

Fix initialization error and update var name

parent e60dce97
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ from homeassistant.components.sun import (STATE_ABOVE_HORIZON,
_LOGGER = logging.getLogger(__name__)
DOMAIN = "influx"
DOMAIN = "influxdb"
DEPENDENCIES = []
DEFAULT_HOST = 'localhost'
......@@ -45,21 +45,21 @@ def setup(hass, config):
host = conf[CONF_HOST]
port = util.convert(conf.get(CONF_PORT), int, DEFAULT_PORT)
dbname = util.convert(conf.get(CONF_DB_NAME), str, DEFAULT_DATABASE)
database = util.convert(conf.get(CONF_DB_NAME), str, DEFAULT_DATABASE)
username = util.convert(conf.get(CONF_USERNAME), str)
password = util.convert(conf.get(CONF_PASSWORD), str)
try:
influx = InfluxDBClient(host=host, port=port, username=username,
password=password, database=dbname)
password=password, database=database)
databases = [i['name'] for i in influx.get_list_database()]
except exceptions.InfluxDBClientError:
_LOGGER.error("Database host is not accessible. "
"Please check your entries in the configuration file.")
return False
if dbname not in databases:
_LOGGER.error("Database %s doesn't exist", dbname)
if database not in databases:
_LOGGER.error("Database %s doesn't exist", database)
return False
def influx_event_listener(event):
......@@ -97,7 +97,7 @@ def setup(hass, config):
try:
influx.write_points(json_body)
except exceptions.InfluxDBClientError:
_LOGGER.exception('Error saving event to Influx')
_LOGGER.exception('Error saving event to InfluxDB')
hass.bus.listen(EVENT_STATE_CHANGED, influx_event_listener)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment