Clean up access to config in various integrations v2 (#33763)
This commit is contained in:
1 parent
d95ffb3aa3
commit
d7e3b0b755
20 files changed
+59
-59
No files matched your search
@@ -30,8 +30,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the aREST binary sensor."""
|
||||
resource = config.get(CONF_RESOURCE)
|
||||
pin = config.get(CONF_PIN)
|
||||
resource = config[CONF_RESOURCE]
|
||||
pin = config[CONF_PIN]
|
||||
device_class = config.get(CONF_DEVICE_CLASS)
|
||||
|
||||
try:
|
||||
|
||||
@@ -51,9 +51,9 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the aREST sensor."""
|
||||
resource = config.get(CONF_RESOURCE)
|
||||
var_conf = config.get(CONF_MONITORED_VARIABLES)
|
||||
pins = config.get(CONF_PINS)
|
||||
resource = config[CONF_RESOURCE]
|
||||
var_conf = config[CONF_MONITORED_VARIABLES]
|
||||
pins = config[CONF_PINS]
|
||||
|
||||
try:
|
||||
response = requests.get(resource, timeout=10).json()
|
||||
|
||||
@@ -40,7 +40,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the aREST switches."""
|
||||
resource = config.get(CONF_RESOURCE)
|
||||
resource = config[CONF_RESOURCE]
|
||||
|
||||
try:
|
||||
response = requests.get(resource, timeout=10)
|
||||
@@ -54,7 +54,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
return False
|
||||
|
||||
dev = []
|
||||
pins = config.get(CONF_PINS)
|
||||
pins = config[CONF_PINS]
|
||||
for pinnum, pin in pins.items():
|
||||
dev.append(
|
||||
ArestSwitchPin(
|
||||
@@ -62,11 +62,11 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
config.get(CONF_NAME, response.json()[CONF_NAME]),
|
||||
pin.get(CONF_NAME),
|
||||
pinnum,
|
||||
pin.get(CONF_INVERT),
|
||||
pin[CONF_INVERT],
|
||||
)
|
||||
)
|
||||
|
||||
functions = config.get(CONF_FUNCTIONS)
|
||||
functions = config[CONF_FUNCTIONS]
|
||||
for funcname, func in functions.items():
|
||||
dev.append(
|
||||
ArestSwitchFunction(
|
||||
|
||||
Reference in new issue
Block a user