本文整理汇总了Python中openzwave.option.ZWaveOption类的典型用法代码示例。如果您正苦于以下问题:Python ZWaveOption类的具体用法?Python ZWaveOption怎么用?Python ZWaveOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ZWaveOption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startup_zwave
def startup_zwave(self, args={}):
ffEvent(self._id,{'zwave':'starting_up'})
zwaveSetup = ZWaveOption(self._port, self._configFile)
zwaveSetup.set_console_output(False)
zwaveSetup.lock()
network = ZWaveNetwork(zwaveSetup, autostart=False)
network.start()
stdout.write("Waking up Zwave (This can take up to 5 minutes)")
for i in xrange(3):
if network.state >= network.STATE_AWAKED:
logging.info('Zwave Network Awake')
break
else:
stdout.write(".")
stdout.flush()
sleep(1)
for x in xrange(3):
if network.state >= network.STATE_READY:
ffEvent(self._id,{'zwave':'network_ready'})
else:
stdout.write(".")
stdout.flush()
sleep(.5)
return network
示例2: __init__
def __init__(self):
self.sensor_events = []
self.device = "/dev/ttyACM0"
config_path = "plugins/python-openzwave/openzwave/config"
user_path = "plugins/python-openzwave/config"
# If using older Z-sticks, use the below device:
# self.device = "/dev/ttyUSB0"
# Change config paths where appropriate
self.options = ZWaveOption(self.device, config_path=config_path,
user_path=user_path, cmd_line="")
# Turn off ozw console output
self.options.set_console_output(False)
self.options.set_save_log_level("Info")
self.options.set_logging(False)
self.options.lock()
self.manager = libopenzwave.PyManager()
self.manager.create()
self.manager.addWatcher(self.event_callback)
self.manager.addDriver(self.device)
print("Starting Z-Wave Network...")
self.network = ZWaveNetwork(self.options, log=None)
# Wait for network to start
while not self.network.state >= self.network.STATE_AWAKED:
time.sleep(1)
print("Z-Wave Network Started")
示例3: test_000_network_start_stop
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
示例4: __init__
def __init__(self, name, location, nodefilename="/opt/seciot/nodenames.json"):
IOTDeviceController.__init__(self, name)
# Restore node stuff
nodefile = open(nodefilename, "r")
nodejson = nodefile.read()
self.node_dict = json.loads(nodejson)
# Init options
device = "/dev/ttyACM0"
sniff = 300.0
options = ZWaveOption(device, config_path="/opt/openzwave/config", user_path=".", cmd_line="")
options.set_logging(False)
options.set_console_output(False)
options.lock()
# Create a network object
self.network = ZWaveNetwork(options, autostart=False)
self.network.set_poll_interval(10, True)
# We connect to the louie dispatcher
dispatcher.connect(self.louie_network_started, ZWaveNetwork.SIGNAL_NETWORK_STARTED)
dispatcher.connect(self.louie_network_failed, ZWaveNetwork.SIGNAL_NETWORK_FAILED)
self.network.start()
# We wait for the network.
print "***** Waiting for network to become ready : "
for i in range(0, 300):
if self.network.state >= self.network.STATE_READY:
print "***** Network is ready"
break
else:
sys.stdout.write(".")
sys.stdout.flush()
time.sleep(1.0)
# We update the name of the controller
self.network.controller.node.name = name
self.network.controller.node.location = location
示例5: _start_network
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')
示例6: _start_network
def _start_network(self):
#Define some manager options
self.options = ZWaveOption(self.device, \
config_path=self.config_path, \
user_path=self.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(self.loglevel_ow)
self.options.set_logging(True)
self.options.lock()
self.network = ZWaveNetwork(self.options, self.log, kvals = False)
self.status_bar.update(status='Start Network')
示例7: setUpClass
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.network = ZWaveNetwork(self.options)
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)
示例8: __init__
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)
示例9: setUpClass
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)
示例10: __init__
def __init__(self, stdscr):
self._curAlert = False
self._alertStack = list()
self._driverInitialized = False
self._options = None
self._network = None
self._listMode = True
self._screen = stdscr
self._version = '0.1 Beta 1'
self._listtop = 0
self._listindex = 0
self._listcount = 0
self._selectedNode = None
self._stop = threading.Event()
self._keys = {
'A' : 'Add',
'B' : 'About',
'D' : 'Delete',
'R' : 'Refresh',
'S' : 'Setup',
'+' : 'Increase',
'-' : 'Decrease',
'1' : 'On',
'0' : 'Off',
'Q' : 'Quit'
}
#self._network = ZWaveWrapper.getInstance(device=self._config['device'], config=self._config['config'], log=None)
self._options = ZWaveOption( \
device="/dev/zwave-aeon-s2", \
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_save_log_level('Debug')
self._options.set_console_output(False)
self._options.set_logging(True)
self._options.lock()
# TODO: add log level to config
# TODO: add log enable/disable to config
# TODO: logging - can ozw log be redirected to file? If so, we can add ability to view/tail log
FORMAT='%(asctime)s\t%(levelname)s\t%(name)s\t%(message)s'
logging.basicConfig(filename='zwaveCommander.log', level=logging.DEBUG, format=FORMAT)
self._log = logging.getLogger('ZWaveCommander')
self._logbar ='\n%s\n' % ('-'*60)
示例11: __init__
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')
示例12: __init__
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)
示例13: create_zwave_options
def create_zwave_options(
device,
config_path = "/usr/local/etc/openzwave", # TODO: Auto-discover
user_path = ".",
cmd_line = ""):
try:
options = ZWaveOption(
device,
config_path=config_path,
user_path=user_path,
cmd_line=cmd_line)
options.set_console_output(False)
options.set_logging(False)
options.lock()
return options
except ZWaveOption:
# TODO: Seems device can only be used by one process at the time. If so,
# try to give a meaningful error message
raise
示例14: setup
def setup(hass, config):
"""Setup Z-Wave.
Will automatically load components to support devices found on the network.
"""
# pylint: disable=global-statement, import-error
global NETWORK
descriptions = conf_util.load_yaml_config_file(
os.path.join(os.path.dirname(__file__), 'services.yaml'))
try:
import libopenzwave
except ImportError:
_LOGGER.error("You are missing required dependency Python Open "
"Z-Wave. Please follow instructions at: "
"https://home-assistant.io/components/zwave/")
return False
from pydispatch import dispatcher
from openzwave.option import ZWaveOption
from openzwave.network import ZWaveNetwork
from openzwave.group import ZWaveGroup
default_zwave_config_path = os.path.join(os.path.dirname(
libopenzwave.__file__), 'config')
# Load configuration
use_debug = config[DOMAIN].get(CONF_DEBUG)
autoheal = config[DOMAIN].get(CONF_AUTOHEAL)
hass.data[DATA_DEVICE_CONFIG] = EntityValues(
config[DOMAIN][CONF_DEVICE_CONFIG],
config[DOMAIN][CONF_DEVICE_CONFIG_DOMAIN],
config[DOMAIN][CONF_DEVICE_CONFIG_GLOB])
# Setup options
options = ZWaveOption(
config[DOMAIN].get(CONF_USB_STICK_PATH),
user_path=hass.config.config_dir,
config_path=config[DOMAIN].get(
CONF_CONFIG_PATH, default_zwave_config_path))
options.set_console_output(use_debug)
options.lock()
NETWORK = ZWaveNetwork(options, autostart=False)
if use_debug:
def log_all(signal, value=None):
"""Log all the signals."""
print("")
print("SIGNAL *****", signal)
if value and signal in (ZWaveNetwork.SIGNAL_VALUE_CHANGED,
ZWaveNetwork.SIGNAL_VALUE_ADDED,
ZWaveNetwork.SIGNAL_SCENE_EVENT,
ZWaveNetwork.SIGNAL_NODE_EVENT,
ZWaveNetwork.SIGNAL_AWAKE_NODES_QUERIED,
ZWaveNetwork.SIGNAL_ALL_NODES_QUERIED):
pprint(_obj_to_dict(value))
print("")
dispatcher.connect(log_all, weak=False)
def value_added(node, value):
"""Called when a value is added to a node on the network."""
for (component,
generic_device_class,
specific_device_class,
command_class,
value_type,
value_genre) in DISCOVERY_COMPONENTS:
_LOGGER.debug("Component=%s Node_id=%s query start",
component, node.node_id)
if node.generic not in generic_device_class and \
None not in generic_device_class:
_LOGGER.debug("node.generic %s not None and in "
"generic_device_class %s",
node.generic, generic_device_class)
continue
if node.specific not in specific_device_class and \
None not in specific_device_class:
_LOGGER.debug("node.specific %s is not None and in "
"specific_device_class %s", node.specific,
specific_device_class)
continue
if value.command_class not in command_class and \
None not in command_class:
_LOGGER.debug("value.command_class %s is not None "
"and in command_class %s",
value.command_class, command_class)
continue
if value_type != value.type and value_type is not None:
_LOGGER.debug("value.type %s != value_type %s",
value.type, value_type)
continue
if value_genre != value.genre and value_genre is not None:
_LOGGER.debug("value.genre %s != value_genre %s",
value.genre, value_genre)
continue
#.........这里部分代码省略.........
示例15: setup
def setup(hass, config):
"""Set up Z-Wave.
Will automatically load components to support devices found on the network.
"""
descriptions = conf_util.load_yaml_config_file(
os.path.join(os.path.dirname(__file__), 'services.yaml'))
from pydispatch import dispatcher
# pylint: disable=import-error
from openzwave.option import ZWaveOption
from openzwave.network import ZWaveNetwork
from openzwave.group import ZWaveGroup
# Load configuration
use_debug = config[DOMAIN].get(CONF_DEBUG)
autoheal = config[DOMAIN].get(CONF_AUTOHEAL)
device_config = EntityValues(
config[DOMAIN][CONF_DEVICE_CONFIG],
config[DOMAIN][CONF_DEVICE_CONFIG_DOMAIN],
config[DOMAIN][CONF_DEVICE_CONFIG_GLOB])
# Setup options
options = ZWaveOption(
config[DOMAIN].get(CONF_USB_STICK_PATH),
user_path=hass.config.config_dir,
config_path=config[DOMAIN].get(CONF_CONFIG_PATH))
options.set_console_output(use_debug)
if CONF_NETWORK_KEY in config[DOMAIN]:
options.addOption("NetworkKey", config[DOMAIN][CONF_NETWORK_KEY])
options.lock()
network = hass.data[DATA_NETWORK] = ZWaveNetwork(options, autostart=False)
hass.data[DATA_DEVICES] = {}
hass.data[DATA_ENTITY_VALUES] = []
if use_debug: # pragma: no cover
def log_all(signal, value=None):
"""Log all the signals."""
print("")
print("SIGNAL *****", signal)
if value and signal in (ZWaveNetwork.SIGNAL_VALUE_CHANGED,
ZWaveNetwork.SIGNAL_VALUE_ADDED,
ZWaveNetwork.SIGNAL_SCENE_EVENT,
ZWaveNetwork.SIGNAL_NODE_EVENT,
ZWaveNetwork.SIGNAL_AWAKE_NODES_QUERIED,
ZWaveNetwork.SIGNAL_ALL_NODES_QUERIED):
pprint(_obj_to_dict(value))
print("")
dispatcher.connect(log_all, weak=False)
def value_added(node, value):
"""Handle new added value to a node on the network."""
# Check if this value should be tracked by an existing entity
for values in hass.data[DATA_ENTITY_VALUES]:
values.check_value(value)
for schema in DISCOVERY_SCHEMAS:
if not check_node_schema(node, schema):
continue
if not check_value_schema(
value,
schema[const.DISC_VALUES][const.DISC_PRIMARY]):
continue
values = ZWaveDeviceEntityValues(
hass, schema, value, config, device_config)
# We create a new list and update the reference here so that
# the list can be safely iterated over in the main thread
new_values = hass.data[DATA_ENTITY_VALUES] + [values]
hass.data[DATA_ENTITY_VALUES] = new_values
component = EntityComponent(_LOGGER, DOMAIN, hass)
def node_added(node):
"""Handle a new node on the network."""
entity = ZWaveNodeEntity(node, network)
node_config = device_config.get(entity.entity_id)
if node_config.get(CONF_IGNORED):
_LOGGER.info(
"Ignoring node entity %s due to device settings",
entity.entity_id)
return
component.add_entities([entity])
def scene_activated(node, scene_id):
"""Handle an activated scene on any node in the network."""
hass.bus.fire(const.EVENT_SCENE_ACTIVATED, {
ATTR_ENTITY_ID: _node_object_id(node),
const.ATTR_OBJECT_ID: _node_object_id(node),
const.ATTR_SCENE_ID: scene_id
})
def node_event_activated(node, value):
#.........这里部分代码省略.........