'Newbie Z-Wave Python read button value
I am trying to get a Z-Wave button (Fibaro Button FGPB101 id: 0x1000 type: 0x010f) to work in my python application.
The important cutout from my python code to understand my question:
class application():
def check_entry_button(self):
node, val_id = self.get_node_id('button')
level = self.network.nodes[node].get_dimmer_level(val_id)
if not self.keep_blinking and self.last_level != level:
print(f'Button level is: {level}')
self.last_level = level
return level > 0
def init_zwave(self):
#Create a network object
device = '/dev/ttyUSB20'
log = 'Debug'
options = ZWaveOption(device, config_path= '../open-zwave/config')
options.set_log_file("OZW_Log.log")
options.set_append_log_file(False)
options.set_console_output(True)
options.set_save_log_level(log)
#options.set_save_log_level('Info')
options.set_logging(False)
options.lock()
self.network = ZWaveNetwork(options, log=None)
for i in range(0,self.zwave_wait):
if self.network.state >= self.network.STATE_AWAKED:
break
else:
time.sleep(self.zwave_sleep)
if self.network.state < self.network.STATE_AWAKED:
print('Network not awake !! Continue and check what happens')
for i in range(0,self.zwave_wait):
if self.network.state >= self.network.STATE_READY:
break
else:
time.sleep(self.zwave_sleep)
if not self.network.is_ready:
print('Network not ready !! Continue and check what happens')
else:
print('Network started')
# Store ids for FIBARO button and Teldus switch for quick acces into the nodes array
self.zwave = {}
for node in self.network.nodes:
if self.network.nodes[node].product_id == '0x1000':
for val in self.network.nodes[node].get_dimmers():
self.zwave['button'] = {'node': node, 'val_id': val}
elif self.network.nodes[node].product_id == '0x0003':
for val in self.network.nodes[node].get_switches():
self.zwave['outlet'] = {'node': node, 'val_id': val}
# Assert we have both button and outlet connected
assert 'button' in self.zwave, 'External Fibaro button did not connect'
assert 'outlet' in self.zwave, 'Teldus pwer outlet did not connect'
def main():
print('Starting app')
app = application()
app.init_zwave()
print('Waiting for key presses')
run_application = True
while run_application:
if app.keep_blinking:
app.toggle_lamp()
# Check if it can be turned off
app.check_lamp_off()
if app.check_entry_button():
# Activate blinkning lamp
app.start_blinking()
run_application = not app.stop
Running the app on my Pi3 initiates the ZWaveNetwork and I see my 3 nodes.
However, when I press the button the message is captured by the controller but my attempt to get the value (get_dimmer_level(val_id)) always returns 0
Below is cutout from running the app (first row matches the fourth row in main():
Waiting for key presses
Button level is: 0
2021-08-10 11:43:21.293 Detail, Node002, Received: 0x01, 0x0d, 0x00, 0x04, 0x00, 0x02, 0x05, 0x5b, 0x03, 0x18, 0x80, 0x01, 0x7e, 0x00, 0x4e
2021-08-10 11:43:21.294 Detail,
2021-08-10 11:43:21.294 Info, Node002, Received Central Scene set from node 2: scene id=1 in 7680 seconds. Sending event notification.
2021-08-10 11:43:21.294 Warning, Node002, No ValueID created for Scene 1
2021-08-10 11:43:36.433 Detail, Node002, Received: 0x01, 0x0d, 0x00, 0x04, 0x00, 0x02, 0x05, 0x5b, 0x03, 0x19, 0x80, 0x01, 0x7e, 0x00, 0x4f
2021-08-10 11:43:36.434 Detail,
2021-08-10 11:43:36.434 Info, Node002, Received Central Scene set from node 2: scene id=1 in 7680 seconds. Sending event notification.
2021-08-10 11:43:36.434 Warning, Node002, No ValueID created for Scene 1
So my main question is how to get the push button value when pressed, e.g. there is network traffic to the controller but I do not get any value different from 0 when reading value with get_dimmer_value
I have done some more instrumentation in the network.py def zwcallback(self, args): function and I could observe that it was only Node003 (A controllable power outlet) that got the SIGNAL_VALUE_CHANGED notificationType thru into the class ZWaveNetwork object.
One major difference between the FIBARO push-button and the power outlet is that the FIBARO goes into sleep but when pressed it wakes up and sends message to the controller which is visible in the above log.
So it appears that the PyManager that is responsible to handle the messages does not handle a node that wakes up and sends a message.
The PyManager does handle the FIBARO during initialization, e.g. the following notificationTypes was handled:
- SIGNAL_NODE_ADDED
- SIGNAL_NODE_PROTOCOL_INFO
- SIGNAL_ESSENTIAL_NODE_QUERIES_COMPLETE
- SIGNAL_VALUE_ADDED
- SIGNAL_GROUP
- SIGNAL_NODE_NAMING
which are the same as for the power outlet which seems to work (I have not yet tried to control it)
Doing some more digging I think my problem is related to that the python-openzwave repo uses an old openzwave library that is version 1.4 based:
2021-08-11 15:02:43.470 Always, OpenZwave Version 1.4.3428 Starting Up
whereas if it would have been the latest openzwave libray built and installed by me:
2021-08-11 15:02:43.470 Always, OpenZwave Version 1.6-1930-ga8aa6341 Starting Up
and we know that I have to use a 1.6 version in order to handle COMMAND_CLASS_CENTRAL_SCENE
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
