Clean up access to config in various integrations v5 ()

pull/35012/head
springstan 2020-04-15 14:10:07 +02:00 committed by GitHub
parent 1ea7229f32
commit d842dacfd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 58 additions and 58 deletions
homeassistant/components
decora_wifi
deutsche_bahn
device_sun_light_trigger
digitalloggers
discogs
discord
dte_energy_bridge
dublin_bus_transport

View File

@ -42,7 +42,7 @@ async def async_setup(hass, config):
if DOMAIN not in config:
return True
hosts = config[DOMAIN].get(CONF_HOSTS)
hosts = config[DOMAIN][CONF_HOSTS]
if not hosts:
hass.async_create_task(
hass.config_entries.flow.async_init(

View File

@ -45,10 +45,10 @@ def setup(hass, config):
"""Set up the Datadog component."""
conf = config[DOMAIN]
host = conf.get(CONF_HOST)
port = conf.get(CONF_PORT)
sample_rate = conf.get(CONF_RATE)
prefix = conf.get(CONF_PREFIX)
host = conf[CONF_HOST]
port = conf[CONF_PORT]
sample_rate = conf[CONF_RATE]
prefix = conf[CONF_PREFIX]
initialize(statsd_host=host, statsd_port=port)

View File

@ -34,8 +34,8 @@ NOTIFICATION_TITLE = "myLeviton Decora Setup"
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Decora WiFi platform."""
email = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
email = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
session = DecoraWiFiSession()
try:

View File

@ -49,11 +49,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Deluge sensors."""
name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
port = config.get(CONF_PORT)
name = config[CONF_NAME]
host = config[CONF_HOST]
username = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
port = config[CONF_PORT]
deluge_api = DelugeRPCClient(host, port, username, password)
try:

View File

@ -37,11 +37,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Deluge switch."""
name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
port = config.get(CONF_PORT)
name = config[CONF_NAME]
host = config[CONF_HOST]
username = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
port = config[CONF_PORT]
deluge_api = DelugeRPCClient(host, port, username, password)
try:

View File

@ -80,7 +80,7 @@ MEDIA_MODES = {
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Denon platform."""
denon = DenonDevice(config.get(CONF_NAME), config.get(CONF_HOST))
denon = DenonDevice(config[CONF_NAME], config[CONF_HOST])
if denon.update():
add_entities([denon])

View File

@ -103,8 +103,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
cache = hass.data[KEY_DENON_CACHE] = set()
# Get config option for show_all_sources and timeout
show_all_sources = config.get(CONF_SHOW_ALL_SOURCES)
timeout = config.get(CONF_TIMEOUT)
show_all_sources = config[CONF_SHOW_ALL_SOURCES]
timeout = config[CONF_TIMEOUT]
# Get config option for additional zones
zones = config.get(CONF_ZONES)

View File

@ -36,9 +36,9 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Deutsche Bahn Sensor."""
start = config.get(CONF_START)
destination = config.get(CONF_DESTINATION)
offset = config.get(CONF_OFFSET)
only_direct = config.get(CONF_ONLY_DIRECT)
destination = config[CONF_DESTINATION]
offset = config[CONF_OFFSET]
only_direct = config[CONF_ONLY_DIRECT]
add_entities([DeutscheBahnSensor(start, destination, offset, only_direct)], True)

View File

@ -65,9 +65,9 @@ async def async_setup(hass, config):
light = hass.components.light
person = hass.components.person
conf = config[DOMAIN]
disable_turn_off = conf.get(CONF_DISABLE_TURN_OFF)
disable_turn_off = conf[CONF_DISABLE_TURN_OFF]
light_group = conf.get(CONF_LIGHT_GROUP)
light_profile = conf.get(CONF_LIGHT_PROFILE)
light_profile = conf[CONF_LIGHT_PROFILE]
device_group = conf.get(CONF_DEVICE_GROUP)

View File

@ -63,10 +63,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
"DHT11": Adafruit_DHT.DHT11,
"DHT22": Adafruit_DHT.DHT22,
}
sensor = available_sensors.get(config.get(CONF_SENSOR))
pin = config.get(CONF_PIN)
temperature_offset = config.get(CONF_TEMPERATURE_OFFSET)
humidity_offset = config.get(CONF_HUMIDITY_OFFSET)
sensor = available_sensors.get(config[CONF_SENSOR])
pin = config[CONF_PIN]
temperature_offset = config[CONF_TEMPERATURE_OFFSET]
humidity_offset = config[CONF_HUMIDITY_OFFSET]
if not sensor:
_LOGGER.error("DHT sensor type is not supported")
@ -74,7 +74,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
data = DHTClient(Adafruit_DHT, sensor, pin)
dev = []
name = config.get(CONF_NAME)
name = config[CONF_NAME]
try:
for variable in config[CONF_MONITORED_CONDITIONS]:

View File

@ -41,7 +41,7 @@ def setup(hass, config):
"""Set up the Digital Ocean component."""
conf = config[DOMAIN]
access_token = conf.get(CONF_ACCESS_TOKEN)
access_token = conf[CONF_ACCESS_TOKEN]
digital = DigitalOcean(access_token)

View File

@ -37,7 +37,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
if not digital:
return False
droplets = config.get(CONF_DROPLETS)
droplets = config[CONF_DROPLETS]
dev = []
for droplet in droplets:

View File

@ -37,7 +37,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
if not digital:
return False
droplets = config.get(CONF_DROPLETS)
droplets = config[CONF_DROPLETS]
dev = []
for droplet in droplets:

View File

@ -47,12 +47,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Find and return DIN III Relay switch."""
host = config.get(CONF_HOST)
controller_name = config.get(CONF_NAME)
user = config.get(CONF_USERNAME)
pswd = config.get(CONF_PASSWORD)
tout = config.get(CONF_TIMEOUT)
cycl = config.get(CONF_CYCLETIME)
host = config[CONF_HOST]
controller_name = config[CONF_NAME]
user = config[CONF_USERNAME]
pswd = config[CONF_PASSWORD]
tout = config[CONF_TIMEOUT]
cycl = config[CONF_CYCLETIME]
power_switch = dlipower.PowerSwitch(
hostname=host, userid=user, password=pswd, timeout=tout, cycletime=cycl

View File

@ -83,7 +83,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
return
sensors = []
for sensor_type in config.get(CONF_MONITORED_CONDITIONS):
for sensor_type in config[CONF_MONITORED_CONDITIONS]:
sensors.append(DiscogsSensor(discogs_data, name, sensor_type))
add_entities(sensors, True)

View File

@ -23,7 +23,7 @@ ATTR_IMAGES = "images"
def get_service(hass, config, discovery_info=None):
"""Get the Discord notification service."""
token = config.get(CONF_TOKEN)
token = config[CONF_TOKEN]
return DiscordNotificationService(hass, token)

View File

@ -44,11 +44,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up a D-Link Smart Plug."""
host = config.get(CONF_HOST)
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
use_legacy_protocol = config.get(CONF_USE_LEGACY_PROTOCOL)
name = config.get(CONF_NAME)
host = config[CONF_HOST]
username = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
use_legacy_protocol = config[CONF_USE_LEGACY_PROTOCOL]
name = config[CONF_NAME]
smartplug = SmartPlug(host, password, username, use_legacy_protocol)
data = SmartPlugData(smartplug)

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)

View File

@ -41,8 +41,8 @@ def setup(hass, config):
hass.data[DOMAIN] = DovadoData(
dovado.Dovado(
config[DOMAIN].get(CONF_USERNAME),
config[DOMAIN].get(CONF_PASSWORD),
config[DOMAIN][CONF_USERNAME],
config[DOMAIN][CONF_PASSWORD],
config[DOMAIN].get(CONF_HOST),
config[DOMAIN].get(CONF_PORT),
)

View File

@ -32,9 +32,9 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the DTE energy bridge sensor."""
name = config.get(CONF_NAME)
ip_address = config.get(CONF_IP_ADDRESS)
version = config.get(CONF_VERSION, 1)
name = config[CONF_NAME]
ip_address = config[CONF_IP_ADDRESS]
version = config[CONF_VERSION]
add_entities([DteEnergyBridgeSensor(ip_address, name, version)], True)

View File

@ -59,9 +59,9 @@ def due_in_minutes(timestamp):
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Dublin public transport sensor."""
name = config.get(CONF_NAME)
stop = config.get(CONF_STOP_ID)
route = config.get(CONF_ROUTE)
name = config[CONF_NAME]
stop = config[CONF_STOP_ID]
route = config[CONF_ROUTE]
data = PublicTransportData(stop, route)
add_entities([DublinPublicTransportSensor(data, stop, route, name)], True)