def setup_platform(hass, config, add_devices, discovery_info=None):
    base_url = config.get("base_url")
    name = config.get("name", "NZBGet")
    username = config.get("username")
    password = config.get("password")
    monitored_types = config.get("monitored_variables", DEFAULT_TYPES)

    if not base_url:
        _LOGGER.error("Missing base_url config for NzbGet")
        return False

    url = "{}/jsonrpc".format(base_url)

    try:
        nzbgetapi = NZBGetAPI(api_url=url,
                              username=username,
                              password=password)
        nzbgetapi.update()
    except (requests.exceptions.ConnectionError,
            requests.exceptions.HTTPError) as conn_err:
        _LOGGER.error("Error setting up NZBGet API: %r", conn_err)
        return False

    devices = []
    for ng_type in monitored_types:
        if ng_type in SENSOR_TYPES:
            new_sensor = NZBGetSensor(api=nzbgetapi,
                                      sensor_type=ng_type,
                                      client_name=name)
            devices.append(new_sensor)
        else:
            _LOGGER.error("Unknown nzbget sensor type: %s", ng_type)
    add_devices(devices)
Set up nzbget sensors.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/sensor/nzbget.py/setup_platform