Add the option to add additional tags when logging to InfluxDB (#2613)

This commit is contained in:
Open Home Automation 2016-07-26 08:01:57 +02:00 committed by Paulus Schoutsen
parent f1632496f0
commit de6f49c06f

View File

@ -33,6 +33,7 @@ CONF_PASSWORD = 'password'
CONF_SSL = 'ssl'
CONF_VERIFY_SSL = 'verify_ssl'
CONF_BLACKLIST = 'blacklist'
CONF_TAGS = 'tags'
# pylint: disable=too-many-locals
@ -56,6 +57,7 @@ def setup(hass, config):
verify_ssl = util.convert(conf.get(CONF_VERIFY_SSL), bool,
DEFAULT_VERIFY_SSL)
blacklist = conf.get(CONF_BLACKLIST, [])
tags = conf.get(CONF_TAGS, {})
try:
influx = InfluxDBClient(host=host, port=port, username=username,
@ -99,6 +101,9 @@ def setup(hass, config):
}
]
for tag in tags:
json_body[0]['tags'][tag] = tags[tag]
try:
influx.write_points(json_body)
except exceptions.InfluxDBClientError: