def DeviceFactory(id, lib=None): """Create the correct device instance based on device type and return it. :return: a :class:`Device` or :class:`DeviceGroup` instance. """ lib = lib or Library() if lib.tdGetDeviceType(id) == const.TELLSTICK_TYPE_GROUP: return DeviceGroup(id, lib=lib) return Device(id, lib=lib)
def __init__(self, library_path=None, callback_dispatcher=None): """Create a new TelldusCore instance. Only one instance should be used per program. :param str library_path: Passed to the :class:`.library.Library` constructor. :param str callback_dispatcher: An instance implementing the :class:`.library.BaseCallbackDispatcher` interface ( e.g. :class:`QueuedCallbackDispatcher` or :class:`AsyncioCallbackDispatcher`) A callback dispatcher must be provided if callbacks are to be used. """ super(TelldusCore, self).__init__() self.lib = Library(library_path, callback_dispatcher)
def __init__(self, id, lib=None): super(Device, self).__init__() lib = lib or Library() super(Device, self).__setattr__('id', id) super(Device, self).__setattr__('lib', lib)