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 2020-04-14 20:38:55 +02:00 committed by GitHub
parent 96aaa25aad
commit e2af216bcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 53 additions and 55 deletions

View file

@ -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