当前位置: 首页>>代码示例>>Python>>正文


Python ZWaveOption.set_log_file方法代码示例

本文整理汇总了Python中openzwave.option.ZWaveOption.set_log_file方法的典型用法代码示例。如果您正苦于以下问题:Python ZWaveOption.set_log_file方法的具体用法?Python ZWaveOption.set_log_file怎么用?Python ZWaveOption.set_log_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openzwave.option.ZWaveOption的用法示例。


在下文中一共展示了ZWaveOption.set_log_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Open_zwave

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
class Open_zwave(HAInterface):
    VERSION='0.0.1'
    awake=False
    ready=False
    nodesdisplayed=False
    
    def __init__(self, *args, **kwargs):
        self._serialDevicePath = kwargs.get('serialDevicePath', None)
        self._options = ZWaveOption(self._serialDevicePath, \
          config_path="/usr/share/python-openzwave/config", \
          user_path=".", cmd_line="")
        self._options.set_log_file("OZW_Log.log")
        self._options.set_append_log_file(False)
        self._options.set_console_output(True)
        #self._options.set_save_log_level(log)
        self._options.set_save_log_level('Info')
        self._options.set_logging(False)
        self._options.lock()
        self._network = ZWaveNetwork(self._options, log=None)       
        super(Open_zwave, self).__init__(self, *args, **kwargs)
        

    def _init(self, *args, **kwargs):   
        super(Open_zwave, self)._init(self, *args, **kwargs)

    def _readInterface(self, lastPacketHash):
        if self._network.state>=self._network.STATE_AWAKED and not self.awake:
            self.awake = True
            self._logger.info("Network Awaked")
        if self._network.state>=self._network.STATE_READY and not self.ready:
            self.ready = True
            self._logger.info("Network Ready")
        if not self.awake:
            time.sleep(1.0)
            self._logger.debug("Not awaked")
            return
        if self.awake and not self.ready:
            time.sleep(1.0)
            self._logger.debug("Not ready")
            return
        if not nodesdisplayed:           
            for node in self._network.nodes:
                print
                print "------------------------------------------------------------"
                print "%s - Name : %s" % (self._network.nodes[node].node_id,self._network.nodes[node].name)
                print "%s - Manufacturer name / id : %s / %s" % (self._network.nodes[node].node_id,self._network.nodes[node].manufacturer_name, self._network.nodes[node].manufacturer_id)
                print "%s - Product name / id / type : %s / %s / %s" % (self._network.nodes[node].node_id,self._network.nodes[node].product_name, self._network.nodes[node].product_id, self._network.nodes[node].product_type)
                print "%s - Version : %s" % (self._network.nodes[node].node_id, self._network.nodes[node].version)
                print "%s - Command classes : %s" % (self._network.nodes[node].node_id,self._network.nodes[node].command_classes_as_string)
                print "%s - Capabilities : %s" % (self._network.nodes[node].node_id,self._network.nodes[node].capabilities)
                print "%s - Neigbors : %s" % (self._network.nodes[node].node_id,self._network.nodes[node].neighbors)
                print "%s - Can sleep : %s" % (self._network.nodes[node].node_id,self._network.nodes[node].can_wake_up())
            nodesdisplayed=True
    
    def version(self):
        self._logger.info("Open_zwave Pytomation Driver version " + self.VERSION)
        self._logger.info("Use openzwave library : %s" % self._network.controller.ozw_library_version)
        self._logger.info("Use python library : %s" % self._network.controller.python_library_version)
        self._logger.info("Use ZWave library : %s" % self._network.controller.library_description)
        
开发者ID:Jstaud,项目名称:pytomation,代码行数:61,代码来源:open_zwave.py

示例2: start_zwnetwork

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
def start_zwnetwork(app):
    options = ZWaveOption(device=app.config['ZWAVE_DEVICE'], config_path=app.config['ZWAVE_DIR'], user_path=app.config['USER_DIR'])
    options.set_log_file("OZW_Log.log")
    options.set_append_log_file(False)
    options.set_console_output(False)
    options.set_save_log_level(app.config['ZWAVE_DEBUG'])
    options.set_logging(app.config['ZWAVE_LOGGING'])
    options.lock()
    zwnetwork = ZWaveNetwork(options)
    return zwnetwork
开发者ID:emanuelliborio,项目名称:python-openzwave,代码行数:12,代码来源:__init__.py

示例3: TestApi

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
class TestApi(TestPyZWave):
    """
    Parent test class for api
    """

    @classmethod
    def setUpClass(self):
        super(TestApi, self).setUpClass()
        self.options = ZWaveOption(device=self.device, user_path=self.userpath)
        self.options.set_log_file("OZW_Log.log")
        self.options.set_append_log_file(False)
        self.options.set_console_output(False)
        self.options.set_save_log_level("Debug")
        self.options.set_logging(True)
        self.options.lock()
        self.ctrl_command_result = None
        dispatcher.connect(self.ctrl_message, ZWaveController.SIGNAL_CONTROLLER)
        self.node_result = None
        dispatcher.connect(self.node_update, ZWaveNetwork.SIGNAL_NODE)
        self.network = ZWaveNetwork(self.options)
        time.sleep(1.0)

    @classmethod
    def tearDownClass(self):
        self.network.stop()
        time.sleep(2.0)
        super(TestApi, self).tearDownClass()
        self.network=None

    def setUp(self):
        self.wait_for_network_state(self.network.STATE_AWAKED, 1)

    def wait_for_queue(self):
        for i in range(0,60):
            if self.network.controller.send_queue_count <= 0:
                break
            else:
                time.sleep(0.5)

    def wait_for_network_state(self, state, multiply=1):
        for i in range(0,SLEEP*multiply):
            if self.network.state>=state:
                break
            else:
                #sys.stdout.write(".")
                #sys.stdout.flush()
                time.sleep(1.0)

    def ctrl_message(self, state, message, network, controller):
        self.ctrl_command_result = state

    def node_update(self, network, node):
        self.node_result = node
开发者ID:emanuelliborio,项目名称:python-openzwave,代码行数:55,代码来源:common.py

示例4: __init__

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
    def __init__(self):

	###################  instanciation de l'objet backend ########################################################


	###### options needed for python openzwave library like config files path, logging, 
        device = configpi.interface
        options = ZWaveOption(device, config_path="/home/pi/git-repo/python-openzwave/openzwave/config", user_path=".", cmd_line="")
        options.set_log_file("OZW.log")
        options.set_append_log_file(False)
        options.set_console_output(False)
        options.set_save_log_level('Warning')
        options.set_logging(True)
        options.lock()

        # creation of the object network using the options entity already created
        self.network = ZWaveNetwork(options, autostart=False)

	###### 	 These dispatchers associate a method to a signal. the signals are generated by the library python-openzwave.
	######   Once the signal is reveived. It's associated method is executed (see "_node_added" example below in "_network_started" method)
        dispatcher.connect(self._network_started, ZWaveNetwork.SIGNAL_NETWORK_STARTED)
        dispatcher.connect(self._network_failed, ZWaveNetwork.SIGNAL_NETWORK_FAILED)
        dispatcher.connect(self._network_ready, ZWaveNetwork.SIGNAL_NETWORK_READY)

	###### backend object attributes
#        self.devices = OrderedDict()  ### will contain the list of nodes in the network
#        self.sensors = OrderedDict()  ### will contain the list of sensors (only) in the network
        self.node_added = False
        self.node_removed = False
	self.timestamps = {}	      ### will contain the time of the last values' update for each sensor
        self.queryStages = {	      ### the diffrent stages that a node object gets through before being ready 
                "None"                  :  1, # Query process hasn't started for this node
                "ProtocolInfo"          :  2, # Retrieve protocol information
                "Probe"                 :  3, # Ping device to see if alive
                "WakeUp"                :  4, # Start wake up process if a sleeping node
                "ManufacturerSpecific1" :  5, # Retrieve manufacturer name and product ids if ProtocolInfo lets us
                "NodeInfo"              :  6, # Retrieve info about supported, controlled command classes
                "SecurityReport"        :  7, # Retrieve a list of Command Classes that require Security
                "ManufacturerSpecific2" :  8, # Retrieve manufacturer name and product ids
                "Versions"              :  9, # Retrieve version information
                "Instances"             : 10, # Retrieve information about multiple command class instances
                "Static"                : 11, # Retrieve static information (doesn't change)
                "Probe1"                : 12, # Ping a device upon starting with configuration
                "Associations"          : 13, # Retrieve information about associations
                "Neighbors"             : 14, # Retrieve node neighbor list
                "Session"               : 15, # Retrieve session information (changes infrequently)
                "Dynamic"               : 16, # Retrieve dynamic information (changes frequently)
                "Configuration"         : 17, # Retrieve configurable parameter information (only done on request)
                "Complete"              : 18  # Query process is completed for this node
        }
开发者ID:wheelin,项目名称:iot_src_report,代码行数:52,代码来源:backend_modif.py

示例5: __init__

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
    def __init__(self, object_group, config):
        Plugin.__init__(self, config=config, object_group=object_group, plugin_name=PLUGIN_NAME)

        # Get parameters from the config file

        if not self.is_enabled():
            return

        # Initialize zwave library
        # Options
        try:
            opts = ZWaveOption(device="/dev/ttyUSB0",
                               config_path="/home/mlamonta/git/python-openzwave/openzwave/config/",
                               user_path="logs")
            opts.set_log_file("./logs/zwave.log")
            opts.set_save_log_level("Alert")
            opts.set_append_log_file(False)
            opts.set_console_output(False)
            opts.set_logging(True)
            opts.lock()
        except ZWaveException as e:
            self.logger.error(str(e))
            return

        # Network
        self.net = ZWaveNetwork(opts)

        self.logger.info("------------------------------------------------------------")
        self.logger.info("Waiting for network awake : ")
        self.logger.info("------------------------------------------------------------")
        for i in range(0, 300):
            if self.net.state >= self.net.STATE_AWAKED:
                self.logger.info("done")
                break
            else:
                time.sleep(1.0)

        if self.net.state < self.net.STATE_AWAKED:
            self.logger.warning("Network is not awake")
            return

        self.logger.info("------------------------------------------------------------")

        for node in self.net.nodes:
            self.logger.info("%s - %s / %s" % (self.net.nodes[node].node_id,
                                               self.net.nodes[node].manufacturer_name,
                                               self.net.nodes[node].product_name) )

        self._initialized = True
开发者ID:lemontongs,项目名称:AllSpark,代码行数:51,代码来源:zwave_control.py

示例6: __init__

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
    def __init__(self):
        device = "/dev/ttyUSB0"
        options = ZWaveOption(device, config_path="/home/rich/openzwave/config", user_path=".", cmd_line="")
        options.set_log_file("OZW_Log.log")
        options.set_append_log_file(False)
        options.set_console_output(False)
        options.set_save_log_level('Debug')
        options.set_logging(True)
        options.lock()

        self.values = {}
        dispatcher.connect(self._network_started, ZWaveNetwork.SIGNAL_NETWORK_STARTED)
        dispatcher.connect(self._network_failed, ZWaveNetwork.SIGNAL_NETWORK_FAILED)
        dispatcher.connect(self._network_ready, ZWaveNetwork.SIGNAL_NETWORK_READY)
        self.network = ZWaveNetwork(options, autostart=False)
开发者ID:richbeales,项目名称:flask-openzwave,代码行数:17,代码来源:backend.py

示例7: TestNetworkStartStop

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
class TestNetworkStartStop(TestPyZWave):

    @classmethod
    def setUpClass(self):
        super(TestNetworkStartStop, self).setUpClass()
        self.options = None
        self.network = None

    @classmethod
    def tearDownClass(self):
        if self.network is not None:
            self.network.stop()
        super(TestNetworkStartStop, self).tearDownClass()

    def test_000_network_start_stop(self):
        self.driver_ready = False
        self.driver_removed = False
        self.options = ZWaveOption(device=self.device, user_path=self.userpath)
        self.options.set_log_file("OZW_Log.log")
        self.options.set_append_log_file(False)
        self.options.set_console_output(False)
        self.options.set_save_log_level("Debug")
        self.options.set_logging(True)
        self.options.lock()
        dispatcher.connect(self.driver_ready_message, ZWaveNetwork.SIGNAL_DRIVER_READY)
        dispatcher.connect(self.driver_removed_message, ZWaveNetwork.SIGNAL_DRIVER_REMOVED)
        self.network = ZWaveNetwork(self.options)
        for i in range(0, SLEEP):
            if self.network.state>=self.network.STATE_AWAKED:
                break
            else:
                time.sleep(1.0)
        self.assertTrue(self.driver_ready)
        self.network.stop()
        for i in range(0, SLEEP):
            if self.network.state==self.network.STATE_STOPPED:
                break
            else:
                time.sleep(1.0)
        self.assertEqual(self.network.state, self.network.STATE_STOPPED)
        #self.assertTrue(self.driver_removed)
        self.network = None

    def driver_ready_message(self, network, controller):
        self.driver_ready = True

    def driver_removed_message(self, network):
        self.driver_removed = True
开发者ID:bdfoster,项目名称:python-openzwave-1,代码行数:50,代码来源:test_network.py

示例8: init_zwave_network

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
def init_zwave_network(device=None, config_path=None, user_path=None, debug=False):
    options = ZWaveOption(device, config_path=config_path, user_path=user_path, cmd_line="")
    options.set_log_file(os.path.join(user_path, "OZW_Log.log"))
    options.set_append_log_file(False)
    options.set_console_output(False)
    options.set_save_log_level('Info')  # ('Info' if debug else 'Warning')
    options.set_logging(True)
    options.lock()

    zwave_network = ZWaveNetwork(options, autostart=False)

    # We connect to the louie dispatcher
    dispatcher.connect(zwave_network_started, ZWaveNetwork.SIGNAL_NETWORK_STARTED)
    dispatcher.connect(zwave_network_failed, ZWaveNetwork.SIGNAL_NETWORK_FAILED)
    dispatcher.connect(zwave_network_ready, ZWaveNetwork.SIGNAL_NETWORK_READY)

    return zwave_network
开发者ID:troolee,项目名称:zwave-agentx,代码行数:19,代码来源:agent.py

示例9: _init

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
    def _init(self, device, config, timeout):
        self.network = None
        self.status = 1
        self.timeout = timeout
        self.device = device
        self.config = config

        options = ZWaveOption(self.device, config_path=self.config, user_path=".", cmd_line="")
        options.set_log_file("OZW_Log.log")
        options.set_append_log_file(False)
        options.set_console_output(False)
        options.set_save_log_level('Debug')
        options.set_logging(True)

        options.lock()
        self.network = ZWaveNetwork(options, autostart=False)

        dispatcher.connect(louie_network_started, ZWaveNetwork.SIGNAL_NETWORK_STARTED)
        dispatcher.connect(louie_network_failed, ZWaveNetwork.SIGNAL_NETWORK_FAILED)
        dispatcher.connect(louie_network_ready, ZWaveNetwork.SIGNAL_NETWORK_READY)

        self.network.start()
开发者ID:RomanGrekov,项目名称:z_gateway,代码行数:24,代码来源:start_network.py

示例10: MainWindow

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]

#.........这里部分代码省略.........
                else :
                    self.status_bar.update(status='Unknowm state "%s"' % state)
                    return False
        else:
            self.status_bar.update(status='Unknown command "%s"' % command)
            return False

    def _unhandled_input(self, key):
        if key == 'esc':
            self.exit()
        elif key == 'tab' or key == 'shift tab':
            if self.framefocus == 'footer':
                self.framefocus = 'body'
            else:
                self.framefocus = 'footer'
            self.frame.set_focus(self.framefocus)
            return True
        elif key == 'enter':
            self.log.info('handled: %s' % repr(key))
            cmd = self.status_bar.get_command()
            self.execute(cmd)
            return True
        elif key == 'f5':
            self.refresh_nodes()
            return True
        else:
            self.log.info('unhandled: %s' % repr(key))

    def _start_network(self):
        #Define some manager options
        self.options = ZWaveOption(self.device, \
          config_path="openzwave/config", \
          user_path=".", cmd_line="")
        self.options.set_log_file("OZW_Log.log")
        self.options.set_append_log_file(False)
        self.options.set_console_output(False)
        self.options.set_save_log_level("Internal")
        self.options.set_logging(True)
        self.options.lock()
        self.network = ZWaveNetwork(self.options, self.log)
        self.status_bar.update(status='Start Network')

    def _connect_louie(self):
        dispatcher.connect(self._louie_network_started, ZWaveNetwork.SIGNAL_NETWORK_STARTED)
        dispatcher.connect(self._louie_network_resetted, ZWaveNetwork.SIGNAL_NETWORK_RESETTED)
        dispatcher.connect(self._louie_network_awaked, ZWaveNetwork.SIGNAL_NETWORK_AWAKED)
        dispatcher.connect(self._louie_network_ready, ZWaveNetwork.SIGNAL_NETWORK_READY)
        dispatcher.connect(self._louie_network_stopped, ZWaveNetwork.SIGNAL_NETWORK_STOPPED)

    def _louie_network_started(self, network):
        self.log.info('OpenZWave network is started : homeid %0.8x - %d nodes were found.' % \
            (network.home_id, network.nodes_count))
        self.network = network
        self.status_bar.update(status='OpenZWave network is started ... Waiting ...')
        self.loop.draw_screen()

    def _louie_network_resetted(self, network):
        self.log.info('OpenZWave network is resetted.')
        self.network = None
        #self._disconnect_louie_node_and_value()
        self.status_bar.update(status='OpenZWave network was resetted ... Waiting ...')
        self.loop.draw_screen()

    def _louie_network_stopped(self, network):
        self.log.info('OpenZWave network is stopped.')
        self.network = None
开发者ID:Bouhmarc,项目名称:python-openzwave,代码行数:70,代码来源:ozwsh.py

示例11: len

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
# Check command line
if len(args) < 1:
        usage()
device = args[0]

# Open the communication with syslogd
loglevel = syslog.LOG_PID
if logstderr:
        loglevel |= syslog.LOG_PERROR
syslog.openlog(NAME, loglevel, syslog.LOG_USER)

# Define some manager options and create a network object
options = ZWaveOption(device, config_path = "./openzwave/config",
			user_path = ".", cmd_line = "")
options.set_log_file(NAME + ".log")
options.set_append_log_file(False)
#options.set_console_output(True)
options.set_console_output(False)
options.set_save_log_level(log)
options.set_logging(True)
options.lock()
network = ZWaveNetwork(options, log = None)

# Add the basic callbacks
dispatcher.connect(louie_network_started,
			ZWaveNetwork.SIGNAL_NETWORK_STARTED)
dispatcher.connect(louie_network_resetted,
			ZWaveNetwork.SIGNAL_NETWORK_RESETTED)
dispatcher.connect(louie_network_ready,
			ZWaveNetwork.SIGNAL_NETWORK_READY)
开发者ID:giometti,项目名称:beaglebone_home_automation_blueprints,代码行数:32,代码来源:zwmanager.py

示例12: Open_zwave

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
class Open_zwave(HAInterface):
    VERSION = '0.0.2'
    awake = False
    ready = False
    nodesdisplayed = False

    def louie_network_ready(network):
	self._logger.info(">>>>>>> Hello from network : I'm ready : %d nodes were found." % self._network.nodes_count)     
	self._logger.info(">>>>>>> Hello from network : my controller is : %s" % self._network.controller)
	dispatcher.connect(self.louie_node_update, ZWaveNetwork.SIGNAL_NODE)
	dispatcher.connect(self.louie_value_update, ZWaveNetwork.SIGNAL_VALUE)

    def louie_node_update(network, node):
    	self._logger.info('>>>>>>> Hello from node : %s.' % node)

    def louie_value_update(network, node, value):
    	self._logger.info('>>>>>>> Hello from value : %s.' % value)

    def __init__(self, *args, **kwargs):
        self._serialDevicePath = kwargs.get('serialDevicePath', None)
        self._options = ZWaveOption(self._serialDevicePath, \
          config_path="/usr/local/etc/openzwave/", \
          user_path=".", cmd_line="")
        self._options.set_log_file("OZW_Log.log")
        self._options.set_append_log_file(False)
        self._options.set_console_output(False)
        #self._options.set_save_log_level(log)
        self._options.set_save_log_level('Info')
        self._options.set_logging(True)
	self._options.set_notify_transactions(True)
        self._options.lock()

        self._network = ZWaveNetwork(self._options, log=None,autostart=False)
	dispatcher.connect(self.louie_network_ready, ZWaveNetwork.SIGNAL_NETWORK_READY)
	self._network.start()
        super(Open_zwave, self).__init__(self, *args, **kwargs)

    def _printNetwork(self, node):
        print
        print "------------------------------------------------------"
        print "%s - Name : %s" % (self._network.nodes[node].node_id,
            self._network.nodes[node].name)
        print "%s - Manufacturer name / id : %s / %s" % (
            self._network.nodes[node].node_id,
            self._network.nodes[node].manufacturer_name,
            self._network.nodes[node].manufacturer_id)
        print "%s - Product name / id / type : %s / %s / %s" % (
            self._network.nodes[node].node_id,
            self._network.nodes[node].product_name,
            self._network.nodes[node].product_id,
            self._network.nodes[node].product_type)
        print "%s - Version : %s" % (self._network.nodes[node].node_id,
            self._network.nodes[node].version)
        print "%s - Command classes : %s" % (self._network.nodes[node].node_id,
            self._network.nodes[node].command_classes_as_string)
        print "%s - Capabilities : %s" % (self._network.nodes[node].node_id,
            self._network.nodes[node].capabilities)
        print "%s - Neighbors : %s" % (self._network.nodes[node].node_id,
            self._network.nodes[node].neighbors)
        print "%s - Can sleep : %s" % (self._network.nodes[node].node_id,
            self._network.nodes[node].can_wake_up())

    def _init(self, *args, **kwargs):
        super(Open_zwave, self)._init(self, *args, **kwargs)

    def _readInterface(self, lastPacketHash):
        if (self._network.state >= self._network.STATE_AWAKED
            and not self.awake):
            self.awake = True
            self._logger.info("Network Awaked")
        if (self._network.state >= self._network.STATE_READY
            and not self.ready):
            self.ready = True
            self._logger.info("Network Ready")
	    self._logger.info("********************************* NETWORK READY ************************************")
        if not self.awake:
            time.sleep(1.0)
            self._logger.debug("Not awaked")
            return
        if self.awake and not self.ready:
            time.sleep(1.0)
            self._logger.debug("Not ready")
            return
        if not self.nodesdisplayed and self.ready:
            for node in self._network.nodes:
                self._printNetwork(node)
            self.nodesdisplayed = True
        time.sleep(1)

    def version(self):
        self._logger.info("Open_zwave Pytomation Driver version " +
                          self.VERSION)
        self._logger.info("Use openzwave library : %s" %
                          self._network.controller.ozw_library_version)
        self._logger.info("Use python library : %s" %
                          self._network.controller.python_library_version)
        self._logger.info("Use ZWave library : %s" %
                          self._network.controller.library_description)

    def on(self, address):
#.........这里部分代码省略.........
开发者ID:E3Dev,项目名称:pytomation,代码行数:103,代码来源:open_zwave.py

示例13: Open_zwave

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
class Open_zwave(HAInterface):
    VERSION = '0.0.4'

    def louie_network_ready(self, network):
        self._logger.info(">>>>>>> Hello from network : I'm ready : %d nodes were found.".format(self._network.nodes_count))
        self._logger.info(">>>>>>> Hello from network : my controller is : {}".format(self._network.controller))
        dispatcher.connect(self.louie_node_update, ZWaveNetwork.SIGNAL_NODE)
        dispatcher.connect(self.louie_value_update, ZWaveNetwork.SIGNAL_VALUE)

    def louie_node_update(self, network, node):
        self._logger.debug('>>>>>>> Hello from node : {}.'.format(node))

    def louie_value_update(self, network, node, value):
        self._logger.debug('>>>>>>> Hello from value : {}'.format(value))
        for lockvalue in self.get_door_locks(node.node_id).values():
            if lockvalue.value_id == value.value_id:
                if value.data:
                    self._onCommand(address=str(node.node_id), command=Command.LOCK)
                else:
                    self._onCommand(address=str(node.node_id), command=Command.UNLOCK)
        for val in self._network.nodes[node.node_id].get_switches():
            if val == value.value_id:
                if value.data:
                    self._onCommand(address=str(node.node_id), command=Command.ON)
                else:
                    self._onCommand(address=str(node.node_id), command=Command.OFF)
        for val in self._network.nodes[node.node_id].get_dimmers() :
            if val == value.value_id:
                #Poll dimmer to ensure ramp up/down completes
                level = value.data
                if self.dimmer_polled_value.has_key(val):
                    self._logger.debug('>>>>>>> Hello from level : {} {}'.format(level, self.dimmer_polled_value[val]))
                    if level == self.dimmer_polled_value[val]:
                        del self.dimmer_polled_value[val]
                        if level < 2:
                            self._onCommand(address=str(node.node_id), command=Command.OFF)
                        elif level > 98:
                            self._onCommand(address=str(node.node_id), command=Command.ON)
                        else:
                            self._onCommand(address=str(node.node_id), command=(Command.LEVEL,level))
                    else:
                        self.dimmer_polled_value[val] = level
                        time.sleep(1)
                        value.refresh()
                else:
                    time.sleep(1)
                    self.dimmer_polled_value[val] = level
                    value.refresh()

    def __init__(self, *args, **kwargs):
        self._serialDevicePath = kwargs.get('serialDevicePath', None)
        self._configpath = kwargs.get('config_path', "/etc/openzwave/")
        super(Open_zwave, self).__init__(self, *args, **kwargs)
        self.dimmer_polled_value = {}

    def _init(self, *args, **kwargs):
        self.awake = False
        self.ready = False
        self.nodesdisplayed = False
        self._options = ZWaveOption(self._serialDevicePath, \
          config_path=self._configpath, \
          user_path=".", cmd_line="")
        self._options.set_log_file("OZW_Log.log")
        self._options.set_append_log_file(False)
        self._options.set_console_output(False)
        #self._options.set_save_log_level(log)
        self._options.set_save_log_level('Info')
        self._options.set_logging(True)
        self._options.set_notify_transactions(True)
        self._options.lock()

        self._network = ZWaveNetwork(self._options, log=None,autostart=False)
        dispatcher.connect(self.louie_network_ready, ZWaveNetwork.SIGNAL_NETWORK_READY)
        self._network.start()
        super(Open_zwave, self)._init(self, *args, **kwargs)

    def _printNetwork(self, node):
        node = self._network.nodes[node]
        self._logger.info("------------------------------------------------------")
        self._logger.info("{} - Name : {}".format(node.node_id,
            node.name))
        self._logger.info("{} - Manufacturer name / id : {} / {}".format(
            node.node_id,
            node.manufacturer_name,
            node.manufacturer_id))
        self._logger.info("{} - Product name / id / type : {} / {} / {}".format(
            node.node_id,
            node.product_name,
            node.product_id,
            node.product_type))
        self._logger.info("{} - Version : {}".format(node.node_id,
            node.version))
        self._logger.info("{} - Command classes : {}".format(node.node_id,
            node.command_classes_as_string))
        self._logger.info("{} - Capabilities : {}".format(node.node_id,
            node.capabilities))
        self._logger.info("{} - Neighbors : {}".format(node.node_id,
            node.neighbors))
        self._logger.info("{} - Can sleep : {}".format(node.node_id,
            node.can_wake_up()))
#.........这里部分代码省略.........
开发者ID:hammj,项目名称:pytomation,代码行数:103,代码来源:open_zwave.py

示例14: AlidronOZW

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
class AlidronOZW(object):

    def __init__(self, device, isac_node):
        self.isac_node = isac_node

        self.signals = {}

        self._ozw_notif_queue = Queue()
        self._running = True
        green.spawn(self._notif_reader)

        self.options = ZWaveOption(
            device,
            config_path='/usr/share/openzwave/config',
            user_path='./user-dir',
            cmd_line=''
        )
        self.options.set_log_file("./user-dir/OZW_Log.log")
        self.options.set_append_log_file(False)
        self.options.set_console_output(False)
        self.options.set_save_log_level('Info')
        self.options.set_logging(False)
        self.options.lock()

        self.network = ZWaveNetwork(self.options, log=None)

        notif_to_func = [
            (ZWaveNetwork.SIGNAL_NETWORK_STARTED,    self.notif_network_started),
            (ZWaveNetwork.SIGNAL_NETWORK_RESETTED,   self.notif_network_resetted),
            (ZWaveNetwork.SIGNAL_NETWORK_READY,      self.notif_network_ready),
            (ZWaveNetwork.SIGNAL_NODE_ADDED,         self.notif_node_added),
            (ZWaveNetwork.SIGNAL_NODE_NAMING,        self.notif_node_named),
            (ZWaveNetwork.SIGNAL_NODE_REMOVED,       self.notif_node_removed),
            (ZWaveNetwork.SIGNAL_VALUE_ADDED,        self.notif_value_added),
            (ZWaveNetwork.SIGNAL_VALUE_CHANGED,      self.notif_value_update),
            (ZWaveNetwork.SIGNAL_VALUE_REMOVED,      self.notif_value_removed),
            (ZWaveNetwork.SIGNAL_CONTROLLER_COMMAND, self.notif_ctrl_message),
            (ZWaveNetwork.SIGNAL_CONTROLLER_WAITING, self.notif_ctrl_message),
        ]
        for notif, func in notif_to_func:
            dispatcher.connect(self._notif_wrapper(func), notif, weak=False)

        # dispatcher.connect(self._notif_wrapper_all, All)

        self.isac_node.add_rpc(self.network_heal)
        self.isac_node.add_rpc(self.controller_add_node, name='add_node')
        self.isac_node.add_rpc(self.controller_remove_node, name='remove_node')
        self.isac_node.add_rpc(self.controller_cancel_command, name='cancel_command')

    # Plumbing

    def _notif_wrapper(self, f):
        def _notif(*args, **kwargs):
            logger.debug('Received notification for %s with args %s and kwargs %s', f.__name__, args, kwargs)
            del kwargs['signal']
            del kwargs['sender']
            self._ozw_notif_queue.put((f, args, kwargs))

        return _notif

    def _notif_wrapper_all(self, *args, **kwargs):
        del kwargs['sender']
        self._ozw_notif_queue.put((self.all_notif, args, kwargs))

    def _notif_reader(self):
        while self._running:
            notif = self._ozw_notif_queue.get()
            if notif is None:
                continue

            f, args, kwargs = notif
            logger.debug('Reading notification for %s with args %s and kwargs %s', f.__name__, args, kwargs)
            f(*args, **kwargs)

    def all_notif(self, *args, **kwargs):
        import time
        from pprint import pformat as pf
        extra = []
        if 'value' in kwargs and kwargs['value']:
            extra.append('value: %s' % self._make_uri(kwargs['node'], kwargs['value']))
        elif 'node' in kwargs and kwargs['node']:
            extra.append('node: %s' % (kwargs['node'].name if kwargs['node'].name else kwargs['node'].node_id))
        extra = ' ; '.join(extra)

        if args:
            logger.warning('>~>~># %f: %s ; %s ; %s', time.time(), pf(args), pf(kwargs), extra)
        else:
            logger.warning('>~>~># %f: %s ; %s', time.time(), pf(kwargs), extra)

    # Notifications from PYOZW

    def notif_network_started(self, network):
        logger.info('//////////// ZWave network is started ////////////')
        logger.debug(
            'OpenZWave network is started: \
            homeid %0.8x - %d nodes were found.',
            network.home_id, network.nodes_count
        )

    def notif_network_resetted(self, network):
#.........这里部分代码省略.........
开发者ID:Alidron,项目名称:alidron-openzwave-controller,代码行数:103,代码来源:ozw.py

示例15: TestApi

# 需要导入模块: from openzwave.option import ZWaveOption [as 别名]
# 或者: from openzwave.option.ZWaveOption import set_log_file [as 别名]
class TestApi(TestPyZWave):
    """
    Parent test class for api
    """

    @classmethod
    def setUpClass(self):
        super(TestApi, self).setUpClass()
        self.options = ZWaveOption(device=self.device, user_path=self.userpath)
        self.options.set_log_file("OZW_Log.log")
        self.options.set_append_log_file(False)
        self.options.set_console_output(self.ozwout)
        self.options.set_save_log_level(self.ozwlog)
        self.options.set_logging(True)
        self.options.lock()
        self.node_result = None
        dispatcher.connect(self.node_update, ZWaveNetwork.SIGNAL_NODE)
        self.network = ZWaveNetwork(self.options)
        self.ctrl_command_result = None
        self.ctrl_command_signal = None
        #dispatcher.connect(self.ctrl_message, ZWaveNetwork.SIGNAL_CONTROLLER_COMMAND)
        time.sleep(1.0)

    @classmethod
    def tearDownClass(self):
        self.network.stop()
        time.sleep(2.0)
        self.network.destroy()
        time.sleep(1.0)
        super(TestApi, self).tearDownClass()
        self.network = None

    def setUp(self):
        self.wait_for_network_state(self.network.STATE_AWAKED, 1)

    def wait_for_queue(self):
        for i in range(0,60):
            if self.network.controller.send_queue_count <= 0:
                break
            else:
                time.sleep(0.5)

    def wait_for_network_state(self, state, multiply=1):
        for i in range(0,SLEEP*multiply):
            if self.network.state>=state:
                break
            else:
                time.sleep(1.0)

    def ctrl_message(self, network, controller, node, node_id,
            state_int, state, state_full,
            error_int, error, error_full,):
        self.ctrl_state_result = state
        self.ctrl_command_signal = {
            'network':network,
            'controller':controller,
            'node':node,
            'node_id':node_id,
            'state_int':state_int,
            'state':state,
            'state_full':state_full,
            'error_int':error_int,
            'error':error,
            'error_full':error_full,
        }

    def ctrl_waiting(self, network, controller,
            state_int, state, state_full):
        self.ctrl_state_result = state

    def node_update(self, network, node):
        self.node_result = node
开发者ID:CadConsultants,项目名称:python-openzwave,代码行数:74,代码来源:common.py


注:本文中的openzwave.option.ZWaveOption.set_log_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。