Fix initialization error and update var name

pull/711/head
Fabian Affolter 2015-12-07 14:28:24 +01:00
parent e60dce9712
commit 0d4f681a4e
1 changed files with 6 additions and 6 deletions

View File

@ -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)