-
Notifications
You must be signed in to change notification settings - Fork 0
/
usage.rb
41 lines (31 loc) · 852 Bytes
/
usage.rb
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
32
33
34
35
36
37
38
39
40
41
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
require 'eventmachine'
require 'em-zwave'
EM.run do
@zwave = EM::Zwave.new
@zwave.add_device('/dev/ttyUSB0')
@zwave.on_notification do |notification|
puts "Notification in user code: #{notification}"
end
@zwave.on_initialization_finished do
puts "Initialization has been finished"
@zwave.nodes.each_value do |node|
puts node.inspect
node.values.each do |value|
puts " - #{value.inspect}"
end
end
@zwave.nodes.each_value do |node|
node.level = 99
end
end
@zwave.on(:value_changed) do |value|
puts "Value Changed: #{value.inspect}"
end
@zwave.on_shutdown do
EM.stop
end
Signal.trap('INT') { @zwave.shutdown }
Signal.trap('TERM') { @zwave.shutdown }
EM::PeriodicTimer.new(1) { puts 'R: .' }
end