Clean up access to config in various integrations v5 (#34206)

This commit is contained in:
springstan authored and GitHub committed 2020-04-15 14:10:07 +02:00
1 parent 1ea7229f32
commit d842dacfd6
21 files changed
+58 -58

No files matched your search

+4 -4
View File
@@ -39,18 +39,18 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
async def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the DNS IP sensor."""
hostname = config.get(CONF_HOSTNAME)
hostname = config[CONF_HOSTNAME]
name = config.get(CONF_NAME)
if not name:
if hostname == DEFAULT_HOSTNAME:
name = DEFAULT_NAME
else:
name = hostname
ipv6 = config.get(CONF_IPV6)
ipv6 = config[CONF_IPV6]
if ipv6:
resolver = config.get(CONF_RESOLVER_IPV6)
resolver = config[CONF_RESOLVER_IPV6]
else:
resolver = config.get(CONF_RESOLVER)
resolver = config[CONF_RESOLVER]
async_add_devices([WanIpSensor(hass, name, hostname, resolver, ipv6)], True)