def DeviceFactory(id, lib=None):
lib = lib or Library()<EOL>if lib.tdGetDeviceType(id) == const.TELLSTICK_TYPE_GROUP:<EOL><INDENT>return DeviceGroup(id, lib=lib)<EOL><DEDENT>return Device(id, lib=lib)<EOL>
Create the correct device instance based on device type and return it.

    :return: a :class:`Device` or :class:`DeviceGroup` instance.