mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Use global variable and merge two if in one
This commit is contained in:
parent
4d5e9f2931
commit
d7094b996a
@ -31,6 +31,7 @@ CONF_USERNAME = 'username'
|
|||||||
CONF_PASSWORD = 'password'
|
CONF_PASSWORD = 'password'
|
||||||
CONF_SSL = 'ssl'
|
CONF_SSL = 'ssl'
|
||||||
CONF_VERIFY_SSL = 'verify_ssl'
|
CONF_VERIFY_SSL = 'verify_ssl'
|
||||||
|
CONF_BLACKLIST = 'blacklist'
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-many-locals
|
# pylint: disable=too-many-locals
|
||||||
@ -53,7 +54,7 @@ def setup(hass, config):
|
|||||||
ssl = util.convert(conf.get(CONF_SSL), bool, DEFAULT_SSL)
|
ssl = util.convert(conf.get(CONF_SSL), bool, DEFAULT_SSL)
|
||||||
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('blacklist', [])
|
blacklist = conf.get(CONF_BLACKLIST, [])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
influx = InfluxDBClient(host=host, port=port, username=username,
|
influx = InfluxDBClient(host=host, port=port, username=username,
|
||||||
@ -69,9 +70,8 @@ def setup(hass, config):
|
|||||||
def influx_event_listener(event):
|
def influx_event_listener(event):
|
||||||
"""Listen for new messages on the bus and sends them to Influx."""
|
"""Listen for new messages on the bus and sends them to Influx."""
|
||||||
state = event.data.get('new_state')
|
state = event.data.get('new_state')
|
||||||
if state is None or state.state in (STATE_UNKNOWN, ''):
|
if state is None or state.state in (STATE_UNKNOWN, '') \
|
||||||
return
|
or state.entity_id in blacklist:
|
||||||
if state.entity_id in blacklist:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user