The commands to use with nodes.
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.
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
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 |
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 |
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() |
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 |
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() |
Represents an interface to switches and dimmers Commands
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 |
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() |
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() |
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 |
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 |
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() |
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 |
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 |
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() |
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() |
The command 0x26 (COMMAND_CLASS_SWITCH_MULTILEVEL) of this node. Set switch to value (using value value_id).
Parameters: |
|
---|
The command 0x33 (COMMAND_CLASS_COLOR) of this node. Set RGBW to value (using value value_id).
Parameters: |
|
---|
The command 0x25 (COMMAND_CLASS_SWITCH_BINARY) of this node. Set switch to value (using value value_id).
Parameters: |
|
---|
The command 0x27 (COMMAND_CLASS_SWITCH_ALL) of this node. Set switches_all to value (using value value_id).
Parameters: |
|
---|
Represents an interface to Sensor Commands
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 |
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() |