def setup_platform(hass, config, add_devices, discovery_info=None):
    resource = config.get(CONF_RESOURCE)
    var_conf = config.get(CONF_MONITORED_VARIABLES)
    pins = config.get('pins', None)

    if resource is None:
        _LOGGER.error('Not all required config keys present: %s',
                      CONF_RESOURCE)
        return False

    try:
        response = requests.get(resource, timeout=10).json()
    except requests.exceptions.MissingSchema:
        _LOGGER.error("Missing resource or schema in configuration. "
                      "Add http:// to your URL.")
        return False
    except requests.exceptions.ConnectionError:
        _LOGGER.error("No route to device at %s. "
                      "Please check the IP address in the configuration file.",
                      resource)
        return False

    arest = ArestData(resource)

    def make_renderer(value_template):
        """Create a renderer based on variable_template value."""
        if value_template is None:
            return lambda value: value

        def _render(value):
            try:
                return template.render(hass, value_template, {'value': value})
            except TemplateError:
                _LOGGER.exception('Error parsing value')
                return value

        return _render

    dev = []

    if var_conf is not None:
        for variable in var_conf:
            if variable['name'] not in response['variables']:
                _LOGGER.error('Variable: "%s" does not exist',
                              variable['name'])
                continue

            renderer = make_renderer(variable.get(CONF_VALUE_TEMPLATE))
            dev.append(ArestSensor(arest,
                                   resource,
                                   config.get('name', response['name']),
                                   variable['name'],
                                   variable=variable['name'],
                                   unit_of_measurement=variable.get(
                                       ATTR_UNIT_OF_MEASUREMENT),
                                   renderer=renderer))

    if pins is not None:
        for pinnum, pin in pins.items():
            renderer = make_renderer(pin.get(CONF_VALUE_TEMPLATE))
            dev.append(ArestSensor(ArestData(resource, pinnum),
                                   resource,
                                   config.get('name', response['name']),
                                   pin.get('name'),
                                   pin=pinnum,
                                   unit_of_measurement=pin.get(
                                       ATTR_UNIT_OF_MEASUREMENT),
                                   renderer=renderer))

    add_devices(dev)


# pylint: disable=too-many-instance-attributes, too-many-arguments
Setup the aREST sensor.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/sensor/arest.py/setup_platform