mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix initialization error and update var name
This commit is contained in:
parent
e60dce9712
commit
0d4f681a4e
@ -17,7 +17,7 @@ from homeassistant.components.sun import (STATE_ABOVE_HORIZON,
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = "influx"
|
DOMAIN = "influxdb"
|
||||||
DEPENDENCIES = []
|
DEPENDENCIES = []
|
||||||
|
|
||||||
DEFAULT_HOST = 'localhost'
|
DEFAULT_HOST = 'localhost'
|
||||||
@ -45,21 +45,21 @@ def setup(hass, config):
|
|||||||
|
|
||||||
host = conf[CONF_HOST]
|
host = conf[CONF_HOST]
|
||||||
port = util.convert(conf.get(CONF_PORT), int, DEFAULT_PORT)
|
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)
|
username = util.convert(conf.get(CONF_USERNAME), str)
|
||||||
password = util.convert(conf.get(CONF_PASSWORD), str)
|
password = util.convert(conf.get(CONF_PASSWORD), str)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
influx = InfluxDBClient(host=host, port=port, username=username,
|
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()]
|
databases = [i['name'] for i in influx.get_list_database()]
|
||||||
except exceptions.InfluxDBClientError:
|
except exceptions.InfluxDBClientError:
|
||||||
_LOGGER.error("Database host is not accessible. "
|
_LOGGER.error("Database host is not accessible. "
|
||||||
"Please check your entries in the configuration file.")
|
"Please check your entries in the configuration file.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if dbname not in databases:
|
if database not in databases:
|
||||||
_LOGGER.error("Database %s doesn't exist", dbname)
|
_LOGGER.error("Database %s doesn't exist", database)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def influx_event_listener(event):
|
def influx_event_listener(event):
|
||||||
@ -97,7 +97,7 @@ def setup(hass, config):
|
|||||||
try:
|
try:
|
||||||
influx.write_points(json_body)
|
influx.write_points(json_body)
|
||||||
except exceptions.InfluxDBClientError:
|
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)
|
hass.bus.listen(EVENT_STATE_CHANGED, influx_event_listener)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user