mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Add the option to add additional tags when logging to InfluxDB (#2613)
This commit is contained in:
parent
f1632496f0
commit
de6f49c06f
@ -33,6 +33,7 @@ CONF_PASSWORD = 'password'
|
|||||||
CONF_SSL = 'ssl'
|
CONF_SSL = 'ssl'
|
||||||
CONF_VERIFY_SSL = 'verify_ssl'
|
CONF_VERIFY_SSL = 'verify_ssl'
|
||||||
CONF_BLACKLIST = 'blacklist'
|
CONF_BLACKLIST = 'blacklist'
|
||||||
|
CONF_TAGS = 'tags'
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-many-locals
|
# pylint: disable=too-many-locals
|
||||||
@ -56,6 +57,7 @@ def setup(hass, config):
|
|||||||
verify_ssl = util.convert(conf.get(CONF_VERIFY_SSL), bool,
|
verify_ssl = util.convert(conf.get(CONF_VERIFY_SSL), bool,
|
||||||
DEFAULT_VERIFY_SSL)
|
DEFAULT_VERIFY_SSL)
|
||||||
blacklist = conf.get(CONF_BLACKLIST, [])
|
blacklist = conf.get(CONF_BLACKLIST, [])
|
||||||
|
tags = conf.get(CONF_TAGS, {})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
influx = InfluxDBClient(host=host, port=port, username=username,
|
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:
|
try:
|
||||||
influx.write_points(json_body)
|
influx.write_points(json_body)
|
||||||
except exceptions.InfluxDBClientError:
|
except exceptions.InfluxDBClientError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user