forked from BrianODell/py-openzwave
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
31 lines (26 loc) · 1.12 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
30
31
import openzwave
from openzwave import PyManager
ZWAVE_SERIAL = '/dev/ttyUSB0'
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(ZWAVE_SERIAL)