def setup_platform(hass, config, add_devices_callback, discovery_info=None):
    import rpi_rf

    gpio = config.get('gpio')
    if not gpio:
        _LOGGER.error("No GPIO specified")
        return False

    rfdevice = rpi_rf.RFDevice(gpio)

    switches = config.get('switches', {})
    devices = []
    for dev_name, properties in switches.items():
        if not properties.get('code_on'):
            _LOGGER.error("%s: code_on not specified", dev_name)
            continue
        if not properties.get('code_off'):
            _LOGGER.error("%s: code_off not specified", dev_name)
            continue

        devices.append(
            RPiRFSwitch(
                hass,
                properties.get('name', dev_name),
                rfdevice,
                properties.get('protocol', None),
                properties.get('pulselength', None),
                properties.get('code_on'),
                properties.get('code_off')))
    if devices:
        rfdevice.enable_tx()

    add_devices_callback(devices)
Find and return switches controlled by a generic RF device via GPIO.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/switch/rpi_rf.py/setup_platform