Clean up access to config in various integrations v4 (#34174)

* Clean up access to config in various integrations v4

* Address review comments
This commit is contained in:
springstan authored and GitHub committed 2020-04-14 20:38:55 +02:00
1 parent 96aaa25aad
commit e2af216bcd
20 files changed
+53 -55

No files matched your search

@@ -40,15 +40,15 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Currencylayer sensor."""
base = config.get(CONF_BASE)
api_key = config.get(CONF_API_KEY)
base = config[CONF_BASE]
api_key = config[CONF_API_KEY]
parameters = {"source": base, "access_key": api_key, "format": 1}
rest = CurrencylayerData(_RESOURCE, parameters)
response = requests.get(_RESOURCE, params=parameters, timeout=10)
sensors = []
for variable in config["quote"]:
for variable in config[CONF_QUOTE]:
sensors.append(CurrencylayerSensor(rest, base, variable))
if "error" in response.json():
return False