-
Notifications
You must be signed in to change notification settings - Fork 13
/
test.py
29 lines (25 loc) · 1.1 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import openzwave
from openzwave import PyManager
options = openzwave.PyOptions()
# Specify the open-zwave config path here
options.create("openzwave/config/","","")
options.lock()
manager = openzwave.PyManager()
manager.create()
# callback order: (notificationtype, homeid, nodeid, ValueID, groupidx, event)
def callback(args):
print('\n%s\n[%s]:\n' % ('-'*20, args['notificationType']))
if args:
print('homeId: 0x%.8x' % args['homeId'])
print('nodeId: %d' % args['nodeId'])
v = args['valueId']
print('valueID: %s' % v['id'])
if v.has_key('groupIndex') and v['groupIndex'] != 0xff: print('GroupIndex: %d' % v['groupIndex'])
if v.has_key('event') and v['event'] != 0xff: print('Event: %d' % v['event'])
if v.has_key('value'): print('Value: %s' % str(v['value']))
if v.has_key('label'): print('Label: %s' % v['label'])
if v.has_key('units'): print('Units: %s' % v['units'])
if v.has_key('readOnly'): print('ReadOnly: %s' % v['readOnly'])
print('%s\n' % ('-'*20,))
manager.addWatcher(callback)
manager.addDriver('/dev/keyspan-2')