def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Transmission sensors."""
    import transmissionrpc
    from transmissionrpc.error import TransmissionError

    host = config.get(CONF_HOST)
    username = config.get(CONF_USERNAME, None)
    password = config.get(CONF_PASSWORD, None)
    port = config.get('port', 9091)

    name = config.get("name", "Transmission")
    if not host:
        _LOGGER.error('Missing config variable %s', CONF_HOST)
        return False

    transmission_api = transmissionrpc.Client(
        host, port=port, user=username, password=password)
    try:
        transmission_api.session_stats()
    except TransmissionError:
        _LOGGER.exception("Connection to Transmission API failed.")
        return False

    # pylint: disable=global-statement
    global _THROTTLED_REFRESH
    _THROTTLED_REFRESH = Throttle(timedelta(seconds=1))(
        transmission_api.session_stats)

    dev = []
    for variable in config['monitored_variables']:
        if variable not in SENSOR_TYPES:
            _LOGGER.error('Sensor type: "%s" does not exist', variable)
        else:
            dev.append(TransmissionSensor(
                variable, transmission_api, name))

    add_devices(dev)
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/sensor/transmission.py/setup_platform/original