From d7094b996a71cc16920819938054596a3f0b3cf0 Mon Sep 17 00:00:00 2001 From: bestlibre Date: Fri, 4 Mar 2016 23:32:24 +0100 Subject: [PATCH] Use global variable and merge two if in one --- homeassistant/components/influxdb.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/influxdb.py b/homeassistant/components/influxdb.py index 8c7e8c26f5b..082430903d0 100644 --- a/homeassistant/components/influxdb.py +++ b/homeassistant/components/influxdb.py @@ -31,6 +31,7 @@ CONF_USERNAME = 'username' CONF_PASSWORD = 'password' CONF_SSL = 'ssl' CONF_VERIFY_SSL = 'verify_ssl' +CONF_BLACKLIST = 'blacklist' # pylint: disable=too-many-locals @@ -53,7 +54,7 @@ def setup(hass, config): ssl = util.convert(conf.get(CONF_SSL), bool, DEFAULT_SSL) verify_ssl = util.convert(conf.get(CONF_VERIFY_SSL), bool, DEFAULT_VERIFY_SSL) - blacklist = conf.get('blacklist', []) + blacklist = conf.get(CONF_BLACKLIST, []) try: influx = InfluxDBClient(host=host, port=port, username=username, @@ -69,9 +70,8 @@ def setup(hass, config): def influx_event_listener(event): """Listen for new messages on the bus and sends them to Influx.""" state = event.data.get('new_state') - if state is None or state.state in (STATE_UNKNOWN, ''): - return - if state.entity_id in blacklist: + if state is None or state.state in (STATE_UNKNOWN, '') \ + or state.entity_id in blacklist: return try: