def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the ISY994 platform."""
    # pylint: disable=too-many-locals
    logger = logging.getLogger(__name__)
    devs = []
    # verify connection
    if ISY is None or not ISY.connected:
        logger.error('A connection has not been made to the ISY controller.')
        return False

    # Import not dimmable nodes and groups
    for (path, node) in ISY.nodes:
        if not node.dimmable and SENSOR_STRING not in node.name:
            if HIDDEN_STRING in path:
                node.name += HIDDEN_STRING
            devs.append(ISYSwitchDevice(node))

    # Import ISY doors programs
    for folder_name, states in (('HA.doors', [STATE_ON, STATE_OFF]),
                                ('HA.switches', [STATE_ON, STATE_OFF])):
        try:
            folder = ISY.programs['My Programs'][folder_name]
        except KeyError:
            # HA.doors folder does not exist
            pass
        else:
            for dtype, name, node_id in folder.children:
                if dtype is 'folder':
                    custom_switch = folder[node_id]
                    try:
                        actions = custom_switch['actions'].leaf
                        assert actions.dtype == 'program', 'Not a program'
                        node = custom_switch['status'].leaf
                    except (KeyError, AssertionError):
                        pass
                    else:
                        devs.append(ISYProgramDevice(name, node, actions,
                                                     states))

    add_devices(devs)
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/switch/isy994.py/setup_platform/original