ruby_home 0.2.0 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +41 -0
- data/CHANGELOG.md +13 -0
- data/README.md +47 -84
- data/examples/air_purifier.rb +67 -0
- data/examples/air_quality_sensor.rb +120 -0
- data/examples/battery_service.rb +59 -0
- data/examples/carbon_dioxide_sensor.rb +79 -0
- data/examples/carbon_monoxide_sensor.rb +79 -0
- data/examples/contact_sensor.rb +67 -0
- data/examples/door.rb +49 -0
- data/examples/fan.rb +31 -0
- data/examples/fan_v2.rb +69 -0
- data/examples/garage_door_opener.rb +72 -0
- data/examples/heater_cooler.rb +93 -0
- data/examples/humidifier_dehumidifier.rb +89 -0
- data/examples/humidity_sensor.rb +63 -0
- data/examples/leak_sensor.rb +67 -0
- data/examples/light_sensor.rb +65 -0
- data/examples/lightbulb.rb +32 -0
- data/examples/lock_mechanism.rb +35 -0
- data/examples/motion_sensor.rb +67 -0
- data/examples/occupancy_sensor.rb +67 -0
- data/examples/outlet.rb +30 -0
- data/examples/security_system.rb +54 -0
- data/examples/smoke_sensor.rb +67 -0
- data/examples/switch.rb +17 -0
- data/examples/television.rb +78 -0
- data/examples/temperature_sensor.rb +63 -0
- data/examples/thermostat.rb +114 -0
- data/examples/window.rb +49 -0
- data/examples/window_covering.rb +73 -0
- data/lib/ruby_home.rb +0 -1
- data/lib/ruby_home/characteristic.rb +7 -1
- data/lib/ruby_home/config/categories.yml +39 -0
- data/lib/ruby_home/config/characteristics.yml +479 -3
- data/lib/ruby_home/config/services.yml +79 -4
- data/lib/ruby_home/configuration.rb +19 -0
- data/lib/ruby_home/dns/service.rb +2 -0
- data/lib/ruby_home/dns/text_record.rb +1 -1
- data/lib/ruby_home/errors.rb +4 -0
- data/lib/ruby_home/factories/characteristic_factory.rb +1 -0
- data/lib/ruby_home/factories/templates/characteristic_template.rb +1 -1
- data/lib/ruby_home/factories/templates/service_template.rb +1 -1
- data/lib/ruby_home/hap/server_handler.rb +4 -13
- data/lib/ruby_home/hap/values/uint8_value.rb +11 -1
- data/lib/ruby_home/http/controllers/application_controller.rb +10 -3
- data/lib/ruby_home/http/controllers/pair_setups_controller.rb +3 -3
- data/lib/ruby_home/http/controllers/pair_verifies_controller.rb +10 -12
- data/lib/ruby_home/http/controllers/pairings_controller.rb +1 -1
- data/lib/ruby_home/http/serializers/characteristic_serializer.rb +13 -5
- data/lib/ruby_home/http/serializers/service_serializer.rb +11 -1
- data/lib/ruby_home/http/services/verify_finish_service.rb +56 -0
- data/lib/ruby_home/http/services/verify_srp_service.rb +32 -41
- data/lib/ruby_home/persistable.rb +4 -12
- data/lib/ruby_home/service.rb +3 -0
- data/lib/ruby_home/version.rb +1 -1
- data/rubyhome.gemspec +7 -7
- data/sbin/service_generator.rb +12 -2
- metadata +65 -39
- data/.travis.yml +0 -31
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'ruby_home'
|
2
|
+
|
3
|
+
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
|
+
heater_cooler = RubyHome::ServiceFactory.create(:heater_cooler,
|
5
|
+
current_temperature: 20, # required
|
6
|
+
target_heater_cooler_state: 1, # required
|
7
|
+
current_heater_cooler_state: 2, # required
|
8
|
+
active: 1, # required
|
9
|
+
name: "heater cooler", # optional
|
10
|
+
rotation_speed: 0, # optional
|
11
|
+
temperature_display_units: 0, # optional
|
12
|
+
heating_threshold_temperature: 20, # optional
|
13
|
+
cooling_threshold_temperature: 10, # optional
|
14
|
+
swing_mode: 1, # optional
|
15
|
+
lock_physical_controls: 0, # optional
|
16
|
+
)
|
17
|
+
|
18
|
+
heater_cooler.current_temperature.after_update do |current_temperature|
|
19
|
+
puts "heater cooler current temperature in celsius #{current_temperature}"
|
20
|
+
end
|
21
|
+
|
22
|
+
target_heater_cooler_state_values = {
|
23
|
+
0 => 'Auto',
|
24
|
+
1 => 'Heat',
|
25
|
+
2 => 'Cool'
|
26
|
+
}
|
27
|
+
heater_cooler.target_heater_cooler_state.after_update do |target_heater_cooler_state|
|
28
|
+
state = target_heater_cooler_state_values[target_heater_cooler_state]
|
29
|
+
puts "heater cooler target heater cooler state is #{state}"
|
30
|
+
end
|
31
|
+
|
32
|
+
current_heater_cooler_state_values = {
|
33
|
+
0 => 'Inactive',
|
34
|
+
1 => 'Idle',
|
35
|
+
2 => 'Heating',
|
36
|
+
3 => 'Cooling'
|
37
|
+
}
|
38
|
+
heater_cooler.current_heater_cooler_state.after_update do |current_heater_cooler_state|
|
39
|
+
state = current_heater_cooler_state_values[current_heater_cooler_state]
|
40
|
+
puts "heater cooler target heater cooler state is #{state}"
|
41
|
+
end
|
42
|
+
|
43
|
+
heater_cooler.active.after_update do |active|
|
44
|
+
if active == 0
|
45
|
+
puts "heater cooler is inactive"
|
46
|
+
elsif active == 1
|
47
|
+
puts "heater cooler is active"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
heater_cooler.rotation_speed.after_update do |rotation_speed|
|
52
|
+
puts "heater cooler is spinning at #{rotation_speed} speed"
|
53
|
+
end
|
54
|
+
|
55
|
+
heater_cooler.temperature_display_units.after_update do |temperature_display_unit|
|
56
|
+
if temperature_display_unit == 0
|
57
|
+
puts "heater cooler temperature display units Celsius"
|
58
|
+
elsif temperature_display_unit == 1
|
59
|
+
puts "heater cooler temperature display units Fahrenheit"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
heater_cooler.heating_threshold_temperature.after_update do |heating_threshold_temperature|
|
64
|
+
# maximum_value: 25
|
65
|
+
# minimum_value: 0
|
66
|
+
# step_value: 0.1
|
67
|
+
puts "heater cooler heating threshold temperature #{heating_threshold_temperature}"
|
68
|
+
end
|
69
|
+
|
70
|
+
heater_cooler.cooling_threshold_temperature.after_update do |cooling_threshold_temperature|
|
71
|
+
# maximum_value: 35
|
72
|
+
# minimum_value: 10
|
73
|
+
# step_value: 0.1
|
74
|
+
puts "heater cooler cooling threshold temperature temperature #{cooling_threshold_temperature}"
|
75
|
+
end
|
76
|
+
|
77
|
+
heater_cooler.swing_mode.after_update do |swing_mode|
|
78
|
+
if swing_mode == 0
|
79
|
+
puts "heater cooler swimg is disabled"
|
80
|
+
elsif swing_mode == 1
|
81
|
+
puts "heater cooler swimg is enabled"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
heater_cooler.lock_physical_controls.after_update do |lock_physical_controls|
|
86
|
+
if lock_physical_controls == 0
|
87
|
+
puts "heater cooler control lock disabled"
|
88
|
+
elsif lock_physical_controls == 1
|
89
|
+
puts "heater cooler control lock enabled"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
RubyHome.run
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'ruby_home'
|
2
|
+
|
3
|
+
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
|
+
humidifier_dehumidifier = RubyHome::ServiceFactory.create(:humidifier_dehumidifier,
|
5
|
+
active: 1, # required
|
6
|
+
target_humidifier_dehumidifier_state: 0, # required
|
7
|
+
current_humidifier_dehumidifier_state: 1, # required
|
8
|
+
current_relative_humidity: 30, # required
|
9
|
+
name: "humidifier dehumidifier", # optional
|
10
|
+
rotation_speed: 0, # optional
|
11
|
+
relative_humidity_humidifier_threshold: 100, # optional
|
12
|
+
relative_humidity_dehumidifier_threshold: 0, # optional
|
13
|
+
water_level: 50, # optional
|
14
|
+
swing_mode: 1, # optional
|
15
|
+
lock_physical_controls: 0, # optional
|
16
|
+
)
|
17
|
+
|
18
|
+
humidifier_dehumidifier.active.after_update do |active|
|
19
|
+
if active == 0
|
20
|
+
puts "humidifier dehumidifier is inactive"
|
21
|
+
elsif active == 1
|
22
|
+
puts "humidifier dehumidifier is active"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
target_humidifier_dehumidifier_state_values = {
|
27
|
+
0 => 'Humidifier or Dehumidifier',
|
28
|
+
1 => 'Humidifier',
|
29
|
+
2 => 'Dehumidifier'
|
30
|
+
}
|
31
|
+
humidifier_dehumidifier.target_humidifier_dehumidifier_state.after_update do |target_humidifier_dehumidifier_state|
|
32
|
+
state = target_humidifier_dehumidifier_state_values[target_humidifier_dehumidifier_state]
|
33
|
+
puts "humidifier dehumidifier target humidifier dehumidifier state is #{state}"
|
34
|
+
end
|
35
|
+
|
36
|
+
current_humidifier_dehumidifier_state_values = {
|
37
|
+
0 => 'Inactive',
|
38
|
+
1 => 'Idle',
|
39
|
+
2 => 'Humidifying',
|
40
|
+
3 => 'Dehumidifying'
|
41
|
+
}
|
42
|
+
humidifier_dehumidifier.current_humidifier_dehumidifier_state.after_update do |current_humidifier_dehumidifier_state|
|
43
|
+
state = current_humidifier_dehumidifier_state_values[current_humidifier_dehumidifier_state]
|
44
|
+
puts "humidifier dehumidifier target humidifier dehumidifier state is #{state}"
|
45
|
+
end
|
46
|
+
|
47
|
+
humidifier_dehumidifier.current_relative_humidity.after_update do |current_relative_humidity|
|
48
|
+
puts "humidifier dehumidifier current relative humidity at #{current_relative_humidity}"
|
49
|
+
end
|
50
|
+
|
51
|
+
humidifier_dehumidifier.rotation_speed.after_update do |rotation_speed|
|
52
|
+
puts "humidifier dehumidifier is spinning at #{rotation_speed} speed"
|
53
|
+
end
|
54
|
+
|
55
|
+
humidifier_dehumidifier.relative_humidity_humidifier_threshold.after_update do |relative_humidity_humidifier_threshold|
|
56
|
+
# maximum_value: 100
|
57
|
+
# minimum_value: 0
|
58
|
+
# step_value: 1
|
59
|
+
puts "humidifier dehumidifier relative humidity humidifier threshold temperature #{relative_humidity_humidifier_threshold}"
|
60
|
+
end
|
61
|
+
|
62
|
+
humidifier_dehumidifier.relative_humidity_dehumidifier_threshold.after_update do |relative_humidity_dehumidifier_threshold|
|
63
|
+
# maximum_value: 100
|
64
|
+
# minimum_value: 0
|
65
|
+
# step_value: 1
|
66
|
+
puts "humidifier dehumidifier relative humidity humidifier threshold temperature #{relative_humidity_dehumidifier_threshold}"
|
67
|
+
end
|
68
|
+
|
69
|
+
humidifier_dehumidifier.water_level.after_update do |water_level|
|
70
|
+
puts "humidifier dehumidifier water level #{water_level}"
|
71
|
+
end
|
72
|
+
|
73
|
+
humidifier_dehumidifier.swing_mode.after_update do |swing_mode|
|
74
|
+
if swing_mode == 0
|
75
|
+
puts "humidifier dehumidifier swimg is disabled"
|
76
|
+
elsif swing_mode == 1
|
77
|
+
puts "humidifier dehumidifier swimg is enabled"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
humidifier_dehumidifier.lock_physical_controls.after_update do |lock_physical_controls|
|
82
|
+
if lock_physical_controls == 0
|
83
|
+
puts "humidifier dehumidifier control lock disabled"
|
84
|
+
elsif lock_physical_controls == 1
|
85
|
+
puts "humidifier dehumidifier control lock enabled"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
RubyHome.run
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'ruby_home'
|
2
|
+
|
3
|
+
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
|
+
humidity_sensor = RubyHome::ServiceFactory.create(:humidity_sensor,
|
5
|
+
current_relative_humidity: 20, # required
|
6
|
+
name: "humidity sensor", # optional
|
7
|
+
status_low_battery: 0, # optional
|
8
|
+
status_tampered: 0, # optional
|
9
|
+
status_fault: 0, # optional
|
10
|
+
status_active: true # optional
|
11
|
+
)
|
12
|
+
|
13
|
+
humidity_sensor.current_relative_humidity.after_update do |current_relative_humidity|
|
14
|
+
puts "humidity sensor current relative humidity #{current_relative_humidity}"
|
15
|
+
end
|
16
|
+
|
17
|
+
humidity_sensor.status_low_battery.after_update do |status_low_battery|
|
18
|
+
if status_low_battery == 0
|
19
|
+
puts "humidity sensor low battery is battery level normal"
|
20
|
+
elsif status_low_battery == 1
|
21
|
+
puts "humidity sensor low battery is battery level low"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
humidity_sensor.status_tampered.after_update do |status_tampered|
|
26
|
+
if status_tampered == 0
|
27
|
+
puts "humidity sensor status_tampered not tampered"
|
28
|
+
elsif status_tampered == 1
|
29
|
+
puts "humidity sensor status_tampered tampered"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
humidity_sensor.status_fault.after_update do |status_fault|
|
34
|
+
if status_fault == 0
|
35
|
+
puts "humidity sensor status_fault no fault"
|
36
|
+
elsif status_fault == 1
|
37
|
+
puts "humidity sensor status_fault general fault"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
humidity_sensor.status_active.after_update do |active|
|
42
|
+
if active
|
43
|
+
puts "humidity sensor is active"
|
44
|
+
else
|
45
|
+
puts "humidity sensor is inactive"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
Thread.new do
|
50
|
+
sleep 30
|
51
|
+
|
52
|
+
loop do
|
53
|
+
humidity_sensor.current_relative_humidity = (0..100).to_a.sample
|
54
|
+
humidity_sensor.status_low_battery = (0..1).to_a.sample
|
55
|
+
humidity_sensor.status_tampered = (0..1).to_a.sample
|
56
|
+
humidity_sensor.status_fault = (0..1).to_a.sample
|
57
|
+
humidity_sensor.status_active = [true, false].to_a.sample
|
58
|
+
|
59
|
+
sleep 10
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
RubyHome.run
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'ruby_home'
|
2
|
+
|
3
|
+
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
|
+
leak_sensor = RubyHome::ServiceFactory.create(:leak_sensor,
|
5
|
+
leak_detected: 0, # required
|
6
|
+
name: "leak sensor", # optional
|
7
|
+
status_low_battery: 0, # optional
|
8
|
+
status_tampered: 0, # optional
|
9
|
+
status_fault: 0, # optional
|
10
|
+
status_active: true # optional
|
11
|
+
)
|
12
|
+
|
13
|
+
leak_sensor.leak_detected.after_update do |leak_detected|
|
14
|
+
if leak_detected == 0
|
15
|
+
puts "leak sensor leak detected leak not detected"
|
16
|
+
elsif leak_detected == 1
|
17
|
+
puts "leak sensor leak detected leak detected"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
leak_sensor.status_low_battery.after_update do |status_low_battery|
|
22
|
+
if status_low_battery == 0
|
23
|
+
puts "leak sensor low battery is battery level normal"
|
24
|
+
elsif status_low_battery == 1
|
25
|
+
puts "leak sensor low battery is battery level low"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
leak_sensor.status_tampered.after_update do |status_tampered|
|
30
|
+
if status_tampered == 0
|
31
|
+
puts "leak sensor status_tampered not tampered"
|
32
|
+
elsif status_tampered == 1
|
33
|
+
puts "leak sensor status_tampered tampered"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
leak_sensor.status_fault.after_update do |status_fault|
|
38
|
+
if status_fault == 0
|
39
|
+
puts "leak sensor status_fault no fault"
|
40
|
+
elsif status_fault == 1
|
41
|
+
puts "leak sensor status_fault general fault"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
leak_sensor.status_active.after_update do |active|
|
46
|
+
if active
|
47
|
+
puts "leak sensor is active"
|
48
|
+
else
|
49
|
+
puts "leak sensor is inactive"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Thread.new do
|
54
|
+
sleep 30
|
55
|
+
|
56
|
+
loop do
|
57
|
+
leak_sensor.leak_detected = (0..1).to_a.sample
|
58
|
+
leak_sensor.status_low_battery = (0..1).to_a.sample
|
59
|
+
leak_sensor.status_tampered = (0..1).to_a.sample
|
60
|
+
leak_sensor.status_fault = (0..1).to_a.sample
|
61
|
+
leak_sensor.status_active = [true, false].to_a.sample
|
62
|
+
|
63
|
+
sleep 10
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
RubyHome.run
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'ruby_home'
|
2
|
+
|
3
|
+
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
|
+
light_sensor = RubyHome::ServiceFactory.create(:light_sensor,
|
5
|
+
current_ambient_light_level: 50000, # required
|
6
|
+
name: "light sensor", # optional
|
7
|
+
status_low_battery: 0, # optional
|
8
|
+
status_tampered: 0, # optional
|
9
|
+
status_fault: 0, # optional
|
10
|
+
status_active: true # optional
|
11
|
+
)
|
12
|
+
|
13
|
+
light_sensor.current_ambient_light_level.after_update do |current_ambient_light_level|
|
14
|
+
# maximum_value: 100000
|
15
|
+
# minimum_value: 0.0001
|
16
|
+
puts "light sensor current ambient light level #{current_ambient_light_level}"
|
17
|
+
end
|
18
|
+
|
19
|
+
light_sensor.status_low_battery.after_update do |status_low_battery|
|
20
|
+
if status_low_battery == 0
|
21
|
+
puts "light sensor low battery is battery level normal"
|
22
|
+
elsif status_low_battery == 1
|
23
|
+
puts "light sensor low battery is battery level low"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
light_sensor.status_tampered.after_update do |status_tampered|
|
28
|
+
if status_tampered == 0
|
29
|
+
puts "light sensor status_tampered not tampered"
|
30
|
+
elsif status_tampered == 1
|
31
|
+
puts "light sensor status_tampered tampered"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
light_sensor.status_fault.after_update do |status_fault|
|
36
|
+
if status_fault == 0
|
37
|
+
puts "light sensor status_fault no fault"
|
38
|
+
elsif status_fault == 1
|
39
|
+
puts "light sensor status_fault general fault"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
light_sensor.status_active.after_update do |active|
|
44
|
+
if active
|
45
|
+
puts "light sensor is active"
|
46
|
+
else
|
47
|
+
puts "light sensor is inactive"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Thread.new do
|
52
|
+
sleep 30
|
53
|
+
|
54
|
+
loop do
|
55
|
+
light_sensor.current_ambient_light_level = (1..100000).to_a.sample
|
56
|
+
light_sensor.status_low_battery = (0..1).to_a.sample
|
57
|
+
light_sensor.status_tampered = (0..1).to_a.sample
|
58
|
+
light_sensor.status_fault = (0..1).to_a.sample
|
59
|
+
light_sensor.status_active = [true, false].to_a.sample
|
60
|
+
|
61
|
+
sleep 10
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
RubyHome.run
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'ruby_home'
|
2
|
+
|
3
|
+
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
|
+
lightbulb = RubyHome::ServiceFactory.create(:lightbulb,
|
5
|
+
on: true, # required
|
6
|
+
name: "lightbulb", # optional
|
7
|
+
brightness: 100, # optional
|
8
|
+
saturation: 100, # optional
|
9
|
+
hue: 360 # optional
|
10
|
+
)
|
11
|
+
|
12
|
+
lightbulb.on.after_update do |on|
|
13
|
+
if on
|
14
|
+
puts "lightbulb is on"
|
15
|
+
else
|
16
|
+
puts "lightbulb is off"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
lightbulb.brightness.after_update do |brightness|
|
21
|
+
puts "lightbulb is at #{brightness} brightness"
|
22
|
+
end
|
23
|
+
|
24
|
+
lightbulb.saturation.after_update do |saturation|
|
25
|
+
puts "lightbulb is at #{saturation} saturation"
|
26
|
+
end
|
27
|
+
|
28
|
+
lightbulb.hue.after_update do |hue|
|
29
|
+
puts "lightbulb is at #{hue} hue"
|
30
|
+
end
|
31
|
+
|
32
|
+
RubyHome.run
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'ruby_home'
|
2
|
+
|
3
|
+
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
|
+
lock_mechanism = RubyHome::ServiceFactory.create(:lock_mechanism,
|
5
|
+
lock_target_state: 1, # required
|
6
|
+
lock_current_state: 1, # required
|
7
|
+
name: "lock" # optional
|
8
|
+
)
|
9
|
+
|
10
|
+
lock_mechanism.lock_target_state.after_update do |lock_target_state|
|
11
|
+
if lock_target_state == 0
|
12
|
+
puts "lock target state is unsecured"
|
13
|
+
|
14
|
+
sleep 1
|
15
|
+
lock_mechanism.lock_current_state = 0
|
16
|
+
elsif lock_target_state == 1
|
17
|
+
puts "lock target state is secured"
|
18
|
+
|
19
|
+
sleep 1
|
20
|
+
lock_mechanism.lock_current_state = 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
lock_current_state_values = {
|
25
|
+
0 => 'Unsecured',
|
26
|
+
1 => 'Secured',
|
27
|
+
2 => 'Jammed',
|
28
|
+
3 => 'Unknown'
|
29
|
+
}
|
30
|
+
lock_mechanism.lock_current_state.after_update do |lock_current_state|
|
31
|
+
state = lock_current_state_values[lock_current_state]
|
32
|
+
puts "lock current state #{state}"
|
33
|
+
end
|
34
|
+
|
35
|
+
RubyHome.run
|