Command documentation

The commands to use with nodes.

This file is part of python-openzwave project https://github.com/OpenZWave/python-openzwave.
platform:Unix, Windows, MacOS X
sinopsis:openzwave wrapper

License : GPL(v3)

python-openzwave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

python-openzwave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with python-openzwave. If not, see http://www.gnu.org/licenses.

class openzwave.command.ZWaveNodeBasic

Represents an interface to BasicCommands I known it’s not necessary as they can be included in the node directly. But it’s a good starting point.

What I want to do is provide an automatic mapping system hidding the mapping classes.

First example, the battery level, it’s not a basic command but don’t care. Its command class is 0x80.

A user should write

if self.handle_command_class(class_id):
    ret=command_Class(...)

The classic way to do it is a classic method of registering. But

Another way : using heritage multiple

ZWaveNode(ZWaveObject, ZWaveNodeBasic, ....) The interface will implement methods command_class_0x80(param1,param2,...) That’s the first thing to do We also can define a property with a friendly name

handle_command_class will do the rest

Another way to do it : A node can manage actuators (switch, dimmer, ...) and sensors (temperature, consummation, temperature)

So we need a kind of mechanism to retrieve commands in a user friendly way Same for sensors.

A good use case is the AN158 Plug-in Meter Appliance Module We will study the following command classes : ‘COMMAND_CLASS_SWITCH_ALL’, ‘COMMAND_CLASS_SWITCH_BINARY’, ‘COMMAND_CLASS_METER’,

The associated values are :

COMMAND_CLASS_SWITCH_ALL : {
    72057594101481476L: {
        'help': '',
        'max': 0L,
        'is_polled': False,
        'units': '',
        'data': 'On and Off Enabled',
        'min': 0L,
        'writeonly': False,
        'label': 'Switch All',
        'readonly': False,
        'data_str': 'On and Off Enabled',
        'type': 'List'}
}
COMMAND_CLASS_SWITCH_BINARY : {
    72057594093060096L: {
        'help': '',
        'max': 0L,
        'is_polled': False,
        'units': '',
        'data': False,
        'min': 0L,
        'writeonly': False,
        'label': 'Switch',
        'readonly': False,
        'data_str': False,
        'type': 'Bool'}
}
COMMAND_CLASS_METER : {
    72057594093273600L: {
        'help': '',
        'max': 0L,
        'is_polled': False,
        'units': '',
        'data': False,
        'min': 0L,
        'writeonly': False,
        'label': 'Exporting',
        'readonly': True,
        'data_str': False,
        'type': 'Bool'},
    72057594101662232L: {
        'help': '',
        'max': 0L,
        'is_polled': False,
        'units': '',
        'data': 'False',
        'min': 0L,
        'writeonly': True,
        'label': 'Reset',
        'readonly': False,
        'data_str': 'False',
        'type': 'Button'},
    72057594093273090L: {
        'help': '',
        'max': 0L,
        'is_polled': False,
        'units': 'kWh',
        'data': 0.0,
        'min': 0L,
        'writeonly': False,
        'label': 'Energy',
        'readonly': True,
        'data_str': 0.0,
        'type': 'Decimal'},
    72057594093273218L: {
        'help': '',
        'max': 0L,
        'is_polled': False,
        'units': 'W',
        'data': 0.0,
        'min': 0L,
        'writeonly': False,
        'label': 'Power',
        'readonly': True,
        'data_str': 0.0,
        'type': 'Decimal'}
}

Another example from an homePro dimmer (not configured in openzwave):

COMMAND_CLASS_SWITCH_MULTILEVEL : {
    72057594109853736L: {
        'help': '',
        'max': 0L,
        'is_polled': False,
        'units': '',
        'data': 'False',
        'min': 0L,
        'writeonly': True,
        'label': 'Dim',
        'readonly': False,
        'data_str': 'False',
        'type': 'Button'},
    72057594109853697L: {
        'help': '',
        'max': 255L,
        'is_polled': False,
        'units': '',
        'data': 69,
        'min': 0L,
        'writeonly': False,
        'label': 'Level',
        'readonly': False,
        'data_str': 69,
        'type': 'Byte'},
    72057594118242369L: {
        'help': '',
        'max': 255L,
        'is_polled': False,
        'units': '',
        'data': 0,
        'min': 0L,
        'writeonly': False,
        'label': 'Start Level',
        'readonly': False,
        'data_str': 0,
        'type': 'Byte'},
    72057594109853720L: {
        'help': '',
        'max': 0L,
        'is_polled': False,
        'units': '',
        'data': 'False',
        'min': 0L,
        'writeonly': True,
        'label': 'Bright',
        'readonly': False,
        'data_str': 'False',
        'type': 'Button'},
    72057594118242352L: {
        'help': '',
        'max': 0L,
        'is_polled': False,
        'units': '',
        'data': False,
        'min': 0L,
        'writeonly': False,
        'label': 'Ignore Start Level',
        'readonly': False,
        'data_str': False,
        'type': 'Bool'}
}

What about the conclusion :

The COMMAND_CLASS_SWITCH_ALL is defined with the same label and use a list as parameter. This should be a configuration parameter. Don’t know what to do for this command class

The COMMAND_CLASS_SWITCH_BINARY use a bool as parameter while COMMAND_CLASS_SWITCH_MULTILEVEL use 2 buttons : Dim and Bright. Dim and Bright must be done in 2 steps : set the level and activate the button.

So we must add one or more lines in the actuators :

Switch : {setter:self.set_command_class_0xYZ(valueId, new), getter:} We must find a way to access the value directly

Bright Dim

So for the COMMAND_CLASS_SWITCH_BINARY we must define a function called Switch (=the label of the value). What happen if we have 2 switches on the node : 2 values I suppose.

COMMAND_CLASS_SWITCH_MULTILEVEL uses 2 commands : 4 when 2 dimmers on the done ? Don’t know but it can.

COMMAND_CLASS_METER export many values : 2 of them sends a decimal and are readonly. They also have a Unit defined ans values are readonly

COMMAND_CLASS_METER are used for sensors only. So we would map every values entries as defined before

Programming : get_switches : retrieve the list of switches on the node is_switch (label) : says if the value with label=label is a switch get_switch (label) : retrieve the value where label=label

can_wake_up()

Check if node contain the command class 0x84 (COMMAND_CLASS_WAKE_UP).

Filter rules are :

command_class = 0x84
Returns:True if the node can wake up
Return type:bool
get_battery_level(value_id=None)

The battery level of this node. The command 0x80 (COMMAND_CLASS_BATTERY) of this node.

Parameters:value_id (int) – The value to retrieve state. If None, retrieve the first value
Returns:The level of this battery
Return type:int
get_battery_levels()

The command 0x80 (COMMAND_CLASS_BATTERY) of this node. Retrieve the list of values to consider as batteries. Filter rules are :

command_class = 0x80 genre = “User” type = “Byte” readonly = True writeonly = False
Returns:The list of switches on this node
Return type:dict()
get_config(value_id=None)

The command 0x70 (COMMAND_CLASS_CONFIGURATION) of this node. Set config to value (using value value_id)

Parameters:value_id (int) – The value to retrieve value. If None, retrieve the first value
Returns:The level of this battery
Return type:int
get_configs(readonly='All', writeonly='All')

The command 0x70 (COMMAND_CLASS_CONFIGURATION) of this node. Retrieve the list of configuration parameters.

Filter rules are :
command_class = 0x70 genre = “Config” readonly = “All” (default) or as passed in arg
Parameters:
  • readonly – whether to retrieve readonly configs
  • writeonly – whether to retrieve writeonly configs
Returns:

The list of configuration parameters

Return type:

dict()

get_power_level(value_id=None)

The power level of this node. The command 0x73 (COMMAND_CLASS_POWERLEVEL) of this node.

Parameters:value_id (int) – The value to retrieve state. If None, retrieve the first value
Returns:The level of this battery
Return type:int
get_power_levels()

The command 0x73 (COMMAND_CLASS_POWERLEVEL) of this node. Retrieve the list of values to consider as power_levels. Filter rules are :

command_class = 0x73 genre = “User” type = “Byte” readonly = True writeonly = False
Returns:The list of switches on this node
Return type:dict()
set_config(value_id, value)

The command 0x70 (COMMAND_CLASS_CONFIGURATION) of this node. Set config to value (using value value_id)

Parameters:
  • value_id (int) – The value to retrieve state
  • value (any) – Appropriate value for given config
class openzwave.command.ZWaveNodeSwitch

Represents an interface to switches and dimmers Commands

get_dimmer_level(value_id)

The command 0x26 (COMMAND_CLASS_SWITCH_MULTILEVEL) of this node. Get the dimmer level (using value value_id).

Parameters:value_id (int) – The value to retrieve level
Returns:The level : a value between 0-99
Return type:int
get_dimmers()

The command 0x26 (COMMAND_CLASS_SWITCH_MULTILEVEL) of this node. Retrieve the list of values to consider as dimmers. Filter rules are :

command_class = 0x26 genre = “User” type = “Bool” readonly = False writeonly = False
Returns:The list of dimmers on this node
Return type:dict()
get_rgbbulbs()

The command 0x33 (COMMAND_CLASS_COLOR) of this node. Retrieve the list of values to consider as RGBW bulbs. Filter rules are :

command_class = 0x33 genre = “User” type = “String” readonly = False writeonly = False
Returns:The list of dimmers on this node
Return type:dict()
get_rgbw(value_id)

The command 0x33 (COMMAND_CLASS_COLOR) of this node. Get the RGW value (using value value_id).

Parameters:value_id (int) – The value to retrieve level
Returns:The level : a value between 0-99
Return type:int
get_switch_all_item(value_id)

The command 0x27 (COMMAND_CLASS_SWITCH_ALL) of this node. Return the current value (using value value_id) of a switch_all.

Parameters:value_id (int) – The value to retrieve switch_all value
Returns:The value of the value
Return type:str
get_switch_all_items(value_id)

The command 0x27 (COMMAND_CLASS_SWITCH_ALL) of this node. Return the all the possible values (using value value_id) of a switch_all.

Parameters:value_id (int) – The value to retrieve items list
Returns:The value of the value
Return type:set()
get_switch_all_state(value_id)

The command 0x27 (COMMAND_CLASS_SWITCH_ALL) of this node. Return the state (using value value_id) of a switch or a dimmer.

Parameters:value_id (int) – The value to retrieve state
Returns:The state of the value
Return type:bool
get_switch_state(value_id)

The command 0x25 (COMMAND_CLASS_SWITCH_BINARY) of this node. Return the state (using value value_id) of a switch.

Parameters:value_id (int) – The value to retrieve state
Returns:The state of the value
Return type:bool
get_switches()

The command 0x25 (COMMAND_CLASS_SWITCH_BINARY) of this node. Retrieve the list of values to consider as switches. Filter rules are :

command_class = 0x25 genre = “User” type = “Bool” readonly = False writeonly = False
Returns:The list of switches on this node
Return type:dict()
get_switches_all()

The command 0x27 (COMMAND_CLASS_SWITCH_ALL) of this node. Retrieve the list of values to consider as switches_all. Filter rules are :

command_class = 0x27 genre = “System” type = “List” readonly = False writeonly = False
Returns:The list of switches on this node
Return type:dict()
set_dimmer(value_id, value)

The command 0x26 (COMMAND_CLASS_SWITCH_MULTILEVEL) of this node. Set switch to value (using value value_id).

Parameters:
  • value_id (int) – The value to retrieve state
  • value (int) – The level : a value between 0-99 or 255. 255 set the level to the last value. 0 turn the dimmer off
set_rgbw(value_id, value)

The command 0x33 (COMMAND_CLASS_COLOR) of this node. Set RGBW to value (using value value_id).

Parameters:
  • value_id (String) – The value to retrieve state
  • value (int) – The level : a RGBW value
set_switch(value_id, value)

The command 0x25 (COMMAND_CLASS_SWITCH_BINARY) of this node. Set switch to value (using value value_id).

Parameters:
  • value_id (int) – The value to retrieve state
  • value (bool) – True or False
set_switch_all(value_id, value)

The command 0x27 (COMMAND_CLASS_SWITCH_ALL) of this node. Set switches_all to value (using value value_id).

Parameters:
  • value_id (int) – The value to retrieve state
  • value (str) – A predefined string
class openzwave.command.ZWaveNodeSensor

Represents an interface to Sensor Commands

get_sensor_value(value_id)

The command 0x30 (COMMAND_CLASS_SENSOR_BINARY) of this node. The command 0x31 (COMMAND_CLASS_SENSOR_MULTILEVEL) of this node. The command 0x32 (COMMAND_CLASS_METER) of this node.

Parameters:value_id (int) – The value to retrieve value
Returns:The state of the sensors
Return type:variable
get_sensors(type='All')

The command 0x30 (COMMAND_CLASS_SENSOR_BINARY) of this node. The command 0x31 (COMMAND_CLASS_SENSOR_MULTILEVEL) of this node. The command 0x32 (COMMAND_CLASS_METER) of this node. Retrieve the list of values to consider as sensors. Filter rules are :

command_class = 0x30-32 genre = “User” readonly = True writeonly = False
Parameters:type ('All' or PyValueTypes) – the type of value
Returns:The list of switches on this node
Return type:dict()
class openzwave.command.ZWaveNodeDoorLock

Represents an interface to door lock and user codes associated with door locks

get_doorlock_logs()

The command 0x4c (COMMAND_CLASS_DOOR_LOCK_LOGGING) of this node. Retrieves the value consisting of log records. Filter rules are :

command_class = 0x4c genre = “User” type = “String” readonly = True
Returns:The dict of log records with value_id as key
Return type:dict()
get_doorlocks()

The command 0x62 (COMMAND_CLASS_DOOR_LOCK) of this node. Retrieves the list of values to consider as doorlocks. Filter rules are :

command_class = 0x62 genre = “User” type = “Bool” readonly = False writeonly = False
Returns:The list of door locks on this node
Return type:dict()
get_usercode(index)

Retrieve particular usercode value by index. Certain values such as user codes have index start from 0 to max number of usercode supported and is useful for getting usercodes by the index.

Parameters:index (int) – The index of usercode value
Returns:The user code at given index on this node
Return type:ZWaveValue
get_usercodes(index='All')

The command 0x63 (COMMAND_CLASS_USER_CODE) of this node. Retrieves the list of value to consider as usercodes. Filter rules are :

command_class = 0x63 genre = “User” type = “Raw” readonly = False writeonly = False
Returns:The list of user codes on this node
Return type:dict()
set_doorlock(value_id, value)

The command 0x62 (COMMAND_CLASS_DOOR_LOCK) of this node. Sets doorlock to value (using value_id).

Parameters:
  • value_id (int) – The value to retrieve state from
  • value (bool) – True or False
set_usercode(value_id, value)

The command 0x63 (COMMAND_CLASS_USER_CODE) of this node. Sets usercode to value (using value_id).

Parameters:
  • value_id (int) – The value to retrieve state from
  • value (str) – User Code as string
set_usercode_at_index(index, value)

The command 0x63 (COMMAND_CLASS_USER_CODE) of this node. Sets usercode to value (using index of value)

Parameters:
  • index (int) – The index of value to retrieve state from
  • value (str) – User Code as string