def imports(args): if args.timeout is None: args.timeout = 2 if args.output == 'txt': print( "-------------------------------------------------------------------------------" ) print("Import libs") print("Try to import libopenzwave") import libopenzwave print("Try to import libopenzwave.PyLogLevels") from libopenzwave import PyLogLevels print("Try to get options") options = libopenzwave.PyOptions(user_path=".", cmd_line="--logging false") options.lock() time.sleep(0.5) print("Try to get manager") manager = libopenzwave.PyManager() manager.create() print("Try to get python_openzwave version") print(manager.getPythonLibraryVersionNumber()) print("Try to get python_openzwave full version") print(manager.getPythonLibraryVersion()) print("Try to get openzwave version") print(manager.getPythonLibraryVersion()) print("Try to get openzwave version") print(manager.getOzwLibraryVersion()) print("Try to get default config path") print(libopenzwave.configPath()) print("Try to destroy manager") manager.destroy() print("Try to destroy options") options.destroy() time.sleep(0.5) print("Try to import openzwave (API)") import openzwave elif args.output == 'raw': import libopenzwave from libopenzwave import PyLogLevels options = libopenzwave.PyOptions(user_path=".", cmd_line="--logging false") options.lock() time.sleep(0.5) manager = libopenzwave.PyManager() manager.create() print("{0}|{1}|{2}|{3}".format(manager.getOzwLibraryVersion(), manager.getPythonLibraryVersionNumber(), manager.getPythonLibraryVersion(), libopenzwave.configPath())) manager.destroy() options.destroy() time.sleep(0.5) import openzwave
def test_010_command_classes(self): manager = libopenzwave.PyManager() CLASSID = re.compile(r"StaticGetCommandClassId\(\)\{ return (.*);") CLASSST = re.compile(r'StaticGetCommandClassName\(\)\{ return "(.*)";') headers = glob.glob( os.path.join(OZWDIR, 'cpp', 'src', 'command_classes', '*.h')) for header in headers: classid = None classst = None if not (header.endswith('CommandClass.h') or header.endswith('CommandClasses.h')): with open(header, 'r') as f: lines = f.readlines() for line in lines: match = CLASSID.search(line) if match: classid = match.group(1) else: match = CLASSST.search(line) if match: classst = match.group(1) print(header) print(classid, ':', classst) self.assertEqual( classst, manager.COMMAND_CLASS_DESC[int(classid, 16)])
def __init__(self, value): """Initialize the zwave rollershutter.""" import libopenzwave from openzwave.network import ZWaveNetwork from pydispatch import dispatcher ZWaveDeviceEntity.__init__(self, value, DOMAIN) self._lozwmgr = libopenzwave.PyManager() self._lozwmgr.create() self._node = value.node self._current_position = None dispatcher.connect(self.value_changed, ZWaveNetwork.SIGNAL_VALUE_CHANGED)
def __init__(self, value): """Initialize the zwave rollershutter.""" import libopenzwave ZWaveDeviceEntity.__init__(self, value, DOMAIN) # pylint: disable=no-member self._lozwmgr = libopenzwave.PyManager() self._lozwmgr.create() self._node = value.node self._current_position = None self._workaround = None if (value.node.manufacturer_id.strip() and value.node.product_id.strip()): specific_sensor_key = (int(value.node.manufacturer_id, 16), int(value.node.product_type, 16)) if specific_sensor_key in DEVICE_MAPPINGS: if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND: _LOGGER.debug("Controller without positioning feedback") self._workaround = 1
def __init__(self, device, config, log=None): self._log = log if self._log is None: self._log = logging.getLogger(__name__) self._log.addHandler(NullHandler()) self._initialized = False self.home_id = None self._controllerNodeId = None self._controller = None self._nodes = dict() self._library_type_name = 'Unknown' self._library_version = 'Unknown' self._device = device options = libopenzwave.PyOptions() options.create(config, '', '--logging false') options.lock() self._manager = libopenzwave.PyManager() self._manager.create() self._manager.addWatcher(self.zwcallback) self._manager.addDriver(device)
def __init__(self, value): """Initialize the zwave rollershutter.""" import libopenzwave from openzwave.network import ZWaveNetwork from pydispatch import dispatcher ZWaveDeviceEntity.__init__(self, value, DOMAIN) self._lozwmgr = libopenzwave.PyManager() self._lozwmgr.create() self._node = value.node self._current_position = None self._workaround = None dispatcher.connect(self.value_changed, ZWaveNetwork.SIGNAL_VALUE_CHANGED) if (value.node.manufacturer_id.strip() and value.node.product_id.strip()): specific_sensor_key = (int(value.node.manufacturer_id, 16), int(value.node.product_type, 16)) if specific_sensor_key in DEVICE_MAPPINGS: if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND: _LOGGER.debug("Controller without positioning feedback") self._workaround = 1
def test_100_start(self): time.sleep(1.0) self.manager = libopenzwave.PyManager() self.manager.create() self.manager.addWatcher(self.zwcallback) time.sleep(1.0) self.manager.addDriver(self.device) for i in range(0,600): if self.driver_ready: break else: time.sleep(0.1) self.assertTrue(self.driver_ready) #~ for i in range(0,600): #~ if self.network_awake: #~ break #~ else: #~ time.sleep(0.1) #~ self.assertTrue(self.network_awake) for i in range(0,1200): if self.network_ready: break else: time.sleep(0.1) self.assertTrue(self.network_ready) self.manager.removeDriver(self.device) for i in range(0,600): if self.driver_removed: break else: time.sleep(0.1) self.assertTrue(self.driver_removed) time.sleep(1.0) self.manager.removeWatcher(self.zwcallback) time.sleep(1.0) self.manager.destroy() time.sleep(1.0) self.manager = None
def start_lib(self): if self.options is None: self.options = libopenzwave.PyOptions(config_path="openzwave/config", \ user_path=self.userpath, cmd_line="--logging false") self.options.lock() if self.manager is None: self.homeid = None self.nodes = {} self.ready = False self.driver_state = None self.driver_ready = None self.driver_removed = None self.driver_failed = None self.driver_reset = None self.network_state = None self.network_ready = None self.network_awake = None self.manager = libopenzwave.PyManager() self.manager.create() self.manager.addWatcher(self.zwcallback) time.sleep(1.0) self.manager.addDriver(self.device) time.sleep(5.0)
elif arg.startswith("--sniff"): temp, sniff = arg.split("=") sniff = float(sniff) if arg.startswith("--help"): print("help : ") print(" --device=/dev/yourdevice ") print(" --log=Info|Debug") print(" --sniff=0 : sniff for zwave messages a number of seconds") exit(0) options = libopenzwave.PyOptions(config_path="../openzwave/config", \ user_path=".", cmd_line="--logging true") # Specify the open-zwave config path here options.lock() manager = libopenzwave.PyManager() manager.create() # callback order: (notificationtype, homeid, nodeid, ValueID, groupidx, event) def callback(args): print('\n-------------------------------------------------') print('\n[{}]:\n'.format(args['notificationType'])) if args: print('homeId: 0x{0:08x}'.format(args['homeId'])) print('nodeId: {}'.format(args['nodeId'])) if 'valueId' in args: v = args['valueId'] print('valueID: {}'.format(v['id'])) if v.has_key('groupIndex') and v['groupIndex'] != 0xff: print('GroupIndex: {}'.format(v['groupIndex']))
def init_device(args): global home_id if args.timeout is None: args.timeout = 15 if args.output == 'txt': print( "-------------------------------------------------------------------------------" ) print("Intialize device {0}".format(args.device)) import libopenzwave print("Try to get options") options = libopenzwave.PyOptions(config_path=args.config_path, user_path=args.user_path, cmd_line="--logging true") options.lock() time.sleep(1.0) print("Try to get manager") manager = libopenzwave.PyManager() manager.create() print("Try to get python_openzwave version") print(manager.getPythonLibraryVersionNumber()) print("Try to get python_openzwave full version") print(manager.getPythonLibraryVersion()) print("Try to get openzwave version") print(manager.getOzwLibraryVersion()) print("Try to get default config path") print(libopenzwave.configPath()) print("Try to add watcher") manager.addWatcher(zwcallback) time.sleep(1.0) manager.addDriver(args.device) print("Wait for notifications ({0}s)".format(args.timeout)) next_print = args.timeout / 10 delta = 0.1 for i in range(0, int(args.timeout / delta)): time.sleep(delta) next_print -= delta if next_print < 0: next_print = args.timeout / 10 print('.') print("Try to remove driver") manager.removeDriver(args.device) time.sleep(3.0) print("Try to remove watcher") manager.removeWatcher(zwcallback) print("Try to destroy manager") manager.destroy() time.sleep(0.2) print("Try to destroy options") options.destroy() time.sleep(1.0) print("Retrieve HomeID") print("{0:08x}".format(home_id)) elif args.output == 'raw': import libopenzwave options = libopenzwave.PyOptions(config_path=args.config_path, user_path=args.user_path, cmd_line="--logging false") options.lock() time.sleep(1.0) manager = libopenzwave.PyManager() manager.create() manager.addWatcher(zwcallback) time.sleep(1.0) manager.addDriver(args.device) next_print = args.timeout / 10 delta = 0.1 for i in range(0, int(args.timeout / delta)): time.sleep(delta) print("{0}|{1}|{2}|{3}|{4:08x}".format( manager.getOzwLibraryVersion(), manager.getPythonLibraryVersionNumber(), manager.getPythonLibraryVersion(), libopenzwave.configPath(), home_id, )) manager.removeDriver(args.device) time.sleep(0.5) manager.removeWatcher(zwcallback) manager.destroy() time.sleep(0.2) options.destroy()
def test_000_init(self): self._manager = libopenzwave.PyManager() self.assertEqual(self._manager.getPythonLibraryVersionNumber(), pyozw_version) vers=re.findall(r'\d+', self._manager.getOzwLibraryVersionNumber()) self.assertEqual(len(vers),3)
def __init__(self, session): libopenzwave.PyManager(self) super(ZWaveManager, self).__init__(session, 'zwave')
def test_050_version(self): time.sleep(1.0) from pyozw_version import pyozw_version manager = libopenzwave.PyManager() version = manager.getPythonLibraryVersion() self.assertEqual(version.find("None"), -1)