Use assignment expressions 12 (#57937)

This commit is contained in:
Marc Mueller 2021-10-20 23:34:08 +02:00 committed by GitHub
parent 7353ea5416
commit 4513ee4ea5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 30 additions and 62 deletions

View file

@ -34,16 +34,14 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Zabbix sensor platform."""
sensors = []
zapi = hass.data[zabbix.DOMAIN]
if not zapi:
if not (zapi := hass.data[zabbix.DOMAIN]):
_LOGGER.error("Zabbix integration hasn't been loaded? zapi is None")
return False
_LOGGER.info("Connected to Zabbix API Version %s", zapi.api_version())
trigger_conf = config.get(_CONF_TRIGGERS)
# The following code seems overly complex. Need to think about this...
if trigger_conf:
if trigger_conf := config.get(_CONF_TRIGGERS):
hostids = trigger_conf.get(_CONF_HOSTIDS)
individual = trigger_conf.get(_CONF_INDIVIDUAL)
name = trigger_conf.get(CONF_NAME)