ruby_home 0.2.5 → 0.2.6
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 +4 -4
- data/.gitignore +2 -2
- data/.rubocop.yml +2 -9
- data/.standard.yml +3 -0
- data/CHANGELOG.md +6 -1
- data/Gemfile +2 -2
- data/Rakefile +4 -4
- data/examples/air_purifier.rb +7 -8
- data/examples/air_quality_sensor.rb +8 -9
- data/examples/battery_service.rb +2 -3
- data/examples/carbon_dioxide_sensor.rb +2 -3
- data/examples/carbon_monoxide_sensor.rb +3 -4
- data/examples/contact_sensor.rb +2 -3
- data/examples/door.rb +5 -6
- data/examples/fan.rb +2 -3
- data/examples/fan_v2.rb +2 -3
- data/examples/garage_door_opener.rb +9 -10
- data/examples/heater_cooler.rb +9 -10
- data/examples/humidifier_dehumidifier.rb +9 -10
- data/examples/humidity_sensor.rb +2 -3
- data/examples/leak_sensor.rb +2 -3
- data/examples/light_sensor.rb +2 -3
- data/examples/lightbulb.rb +2 -3
- data/examples/lock_mechanism.rb +6 -7
- data/examples/motion_sensor.rb +2 -3
- data/examples/occupancy_sensor.rb +2 -3
- data/examples/outlet.rb +2 -3
- data/examples/security_system.rb +12 -13
- data/examples/smoke_sensor.rb +2 -3
- data/examples/switch.rb +2 -3
- data/examples/television.rb +8 -13
- data/examples/temperature_sensor.rb +2 -3
- data/examples/thermostat.rb +10 -11
- data/examples/window.rb +5 -6
- data/examples/window_covering.rb +5 -6
- data/lib/ruby_home.rb +21 -21
- data/lib/ruby_home/accessory.rb +1 -1
- data/lib/ruby_home/accessory_collection.rb +6 -6
- data/lib/ruby_home/accessory_info.rb +18 -18
- data/lib/ruby_home/characteristic.rb +8 -8
- data/lib/ruby_home/characteristic_collection.rb +13 -13
- data/lib/ruby_home/config/characteristics.yml +30 -635
- data/lib/ruby_home/config/manual_characteristics.yml +278 -0
- data/lib/ruby_home/config/manual_services.yml +45 -0
- data/lib/ruby_home/config/services.yml +329 -370
- data/lib/ruby_home/configuration.rb +4 -4
- data/lib/ruby_home/device_id.rb +3 -3
- data/lib/ruby_home/dns/service.rb +4 -6
- data/lib/ruby_home/dns/text_record.rb +9 -9
- data/lib/ruby_home/errors.rb +1 -0
- data/lib/ruby_home/factories/characteristic_factory.rb +37 -37
- data/lib/ruby_home/factories/service_factory.rb +72 -72
- data/lib/ruby_home/factories/templates/characteristic_template.rb +5 -5
- data/lib/ruby_home/factories/templates/service_template.rb +11 -10
- data/lib/ruby_home/hap/crypto/chacha20poly1305.rb +2 -2
- data/lib/ruby_home/hap/crypto/hkdf.rb +4 -4
- data/lib/ruby_home/hap/crypto/session_key.rb +7 -7
- data/lib/ruby_home/hap/decrypter.rb +8 -8
- data/lib/ruby_home/hap/encrypter.rb +5 -6
- data/lib/ruby_home/hap/ev_response.rb +17 -17
- data/lib/ruby_home/hap/hap_request.rb +1 -1
- data/lib/ruby_home/hap/server.rb +4 -4
- data/lib/ruby_home/hap/server_handler.rb +8 -10
- data/lib/ruby_home/hap/session.rb +22 -22
- data/lib/ruby_home/hap/values/base_value.rb +3 -3
- data/lib/ruby_home/hap/values/bool_value.rb +4 -4
- data/lib/ruby_home/hap/values/float_value.rb +4 -4
- data/lib/ruby_home/hap/values/identify_value.rb +1 -1
- data/lib/ruby_home/hap/values/int32_value.rb +4 -4
- data/lib/ruby_home/hap/values/null_value.rb +1 -1
- data/lib/ruby_home/hap/values/string_value.rb +11 -11
- data/lib/ruby_home/hap/values/uint32_value.rb +5 -5
- data/lib/ruby_home/hap/values/uint8_value.rb +14 -14
- data/lib/ruby_home/hex_helper.rb +3 -3
- data/lib/ruby_home/http/application.rb +7 -7
- data/lib/ruby_home/http/controllers/accessories_controller.rb +3 -3
- data/lib/ruby_home/http/controllers/application_controller.rb +6 -6
- data/lib/ruby_home/http/controllers/characteristics_controller.rb +29 -29
- data/lib/ruby_home/http/controllers/identify_controller.rb +10 -10
- data/lib/ruby_home/http/controllers/pair_setups_controller.rb +18 -18
- data/lib/ruby_home/http/controllers/pair_verifies_controller.rb +9 -9
- data/lib/ruby_home/http/controllers/pairings_controller.rb +5 -5
- data/lib/ruby_home/http/serializers/accessory_serializer.rb +5 -5
- data/lib/ruby_home/http/serializers/characteristic_serializer.rb +24 -24
- data/lib/ruby_home/http/serializers/characteristic_value_serializer.rb +5 -5
- data/lib/ruby_home/http/serializers/object_serializer.rb +1 -1
- data/lib/ruby_home/http/serializers/service_serializer.rb +9 -9
- data/lib/ruby_home/http/serializers/uuid_helper.rb +2 -2
- data/lib/ruby_home/http/services/session_notifier.rb +8 -8
- data/lib/ruby_home/http/services/start_srp_service.rb +3 -3
- data/lib/ruby_home/http/services/verify_finish_service.rb +22 -22
- data/lib/ruby_home/http/services/verify_srp_service.rb +22 -22
- data/lib/ruby_home/identifier_cache.rb +4 -5
- data/lib/ruby_home/password.rb +14 -14
- data/lib/ruby_home/persistable.rb +22 -7
- data/lib/ruby_home/service.rb +3 -3
- data/lib/ruby_home/service_collection.rb +1 -1
- data/lib/ruby_home/version.rb +1 -1
- data/rubyhome.gemspec +31 -31
- data/sbin/characteristic_generator.rb +22 -24
- data/sbin/service_generator.rb +36 -27
- metadata +25 -8
data/examples/humidity_sensor.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
humidity_sensor = RubyHome::ServiceFactory.create(:humidity_sensor,
|
@@ -7,8 +7,7 @@ humidity_sensor = RubyHome::ServiceFactory.create(:humidity_sensor,
|
|
7
7
|
status_low_battery: 0, # optional
|
8
8
|
status_tampered: 0, # optional
|
9
9
|
status_fault: 0, # optional
|
10
|
-
status_active: true # optional
|
11
|
-
)
|
10
|
+
status_active: true) # optional
|
12
11
|
|
13
12
|
humidity_sensor.current_relative_humidity.after_update do |current_relative_humidity|
|
14
13
|
puts "humidity sensor current relative humidity #{current_relative_humidity}"
|
data/examples/leak_sensor.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
leak_sensor = RubyHome::ServiceFactory.create(:leak_sensor,
|
@@ -7,8 +7,7 @@ leak_sensor = RubyHome::ServiceFactory.create(:leak_sensor,
|
|
7
7
|
status_low_battery: 0, # optional
|
8
8
|
status_tampered: 0, # optional
|
9
9
|
status_fault: 0, # optional
|
10
|
-
status_active: true # optional
|
11
|
-
)
|
10
|
+
status_active: true) # optional
|
12
11
|
|
13
12
|
leak_sensor.leak_detected.after_update do |leak_detected|
|
14
13
|
if leak_detected == 0
|
data/examples/light_sensor.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
light_sensor = RubyHome::ServiceFactory.create(:light_sensor,
|
@@ -7,8 +7,7 @@ light_sensor = RubyHome::ServiceFactory.create(:light_sensor,
|
|
7
7
|
status_low_battery: 0, # optional
|
8
8
|
status_tampered: 0, # optional
|
9
9
|
status_fault: 0, # optional
|
10
|
-
status_active: true # optional
|
11
|
-
)
|
10
|
+
status_active: true) # optional
|
12
11
|
|
13
12
|
light_sensor.current_ambient_light_level.after_update do |current_ambient_light_level|
|
14
13
|
# maximum_value: 100000
|
data/examples/lightbulb.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
lightbulb = RubyHome::ServiceFactory.create(:lightbulb,
|
@@ -6,8 +6,7 @@ lightbulb = RubyHome::ServiceFactory.create(:lightbulb,
|
|
6
6
|
name: "lightbulb", # optional
|
7
7
|
brightness: 100, # optional
|
8
8
|
saturation: 100, # optional
|
9
|
-
hue: 360 # optional
|
10
|
-
)
|
9
|
+
hue: 360) # optional
|
11
10
|
|
12
11
|
lightbulb.on.after_update do |on|
|
13
12
|
if on
|
data/examples/lock_mechanism.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
lock_mechanism = RubyHome::ServiceFactory.create(:lock_mechanism,
|
5
5
|
lock_target_state: 1, # required
|
6
6
|
lock_current_state: 1, # required
|
7
|
-
name: "lock" # optional
|
8
|
-
)
|
7
|
+
name: "lock") # optional
|
9
8
|
|
10
9
|
lock_mechanism.lock_target_state.after_update do |lock_target_state|
|
11
10
|
if lock_target_state == 0
|
@@ -22,10 +21,10 @@ lock_mechanism.lock_target_state.after_update do |lock_target_state|
|
|
22
21
|
end
|
23
22
|
|
24
23
|
lock_current_state_values = {
|
25
|
-
0 =>
|
26
|
-
1 =>
|
27
|
-
2 =>
|
28
|
-
3 =>
|
24
|
+
0 => "Unsecured",
|
25
|
+
1 => "Secured",
|
26
|
+
2 => "Jammed",
|
27
|
+
3 => "Unknown"
|
29
28
|
}
|
30
29
|
lock_mechanism.lock_current_state.after_update do |lock_current_state|
|
31
30
|
state = lock_current_state_values[lock_current_state]
|
data/examples/motion_sensor.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
motion_sensor = RubyHome::ServiceFactory.create(:motion_sensor,
|
@@ -7,8 +7,7 @@ motion_sensor = RubyHome::ServiceFactory.create(:motion_sensor,
|
|
7
7
|
status_low_battery: 0, # optional
|
8
8
|
status_tampered: 0, # optional
|
9
9
|
status_fault: 0, # optional
|
10
|
-
status_active: true # optional
|
11
|
-
)
|
10
|
+
status_active: true) # optional
|
12
11
|
|
13
12
|
motion_sensor.motion_detected.after_update do |motion_detected|
|
14
13
|
if motion_detected
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
occupancy_sensor = RubyHome::ServiceFactory.create(:occupancy_sensor,
|
@@ -7,8 +7,7 @@ occupancy_sensor = RubyHome::ServiceFactory.create(:occupancy_sensor,
|
|
7
7
|
status_low_battery: 0, # optional
|
8
8
|
status_tampered: 0, # optional
|
9
9
|
status_fault: 0, # optional
|
10
|
-
status_active: true # optional
|
11
|
-
)
|
10
|
+
status_active: true) # optional
|
12
11
|
|
13
12
|
occupancy_sensor.occupancy_detected.after_update do |occupancy_detected|
|
14
13
|
if occupancy_detected == 0
|
data/examples/outlet.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
outlet = RubyHome::ServiceFactory.create(:outlet,
|
5
5
|
outlet_in_use: false, # required
|
6
6
|
on: false, # required
|
7
|
-
name: "occupancy sensor"
|
8
|
-
)
|
7
|
+
name: "occupancy sensor") # optional
|
9
8
|
|
10
9
|
outlet.outlet_in_use.after_update do |outlet_in_use|
|
11
10
|
if outlet_in_use
|
data/examples/security_system.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
security_system = RubyHome::ServiceFactory.create(:security_system,
|
5
5
|
security_system_target_state: 0, # required
|
6
6
|
security_system_current_state: 0, # required
|
7
|
-
name:
|
7
|
+
name: "security system", # optional
|
8
8
|
security_system_alarm_type: 0, # optional
|
9
9
|
status_tampered: 0, # optional
|
10
|
-
status_fault: 0 # optional
|
11
|
-
)
|
10
|
+
status_fault: 0) # optional
|
12
11
|
|
13
12
|
security_system_target_state_values = {
|
14
|
-
0 =>
|
15
|
-
1 =>
|
16
|
-
2 =>
|
17
|
-
3 =>
|
13
|
+
0 => "Stay Arm",
|
14
|
+
1 => "Away Arm",
|
15
|
+
2 => "Night Arm",
|
16
|
+
3 => "Disarm"
|
18
17
|
}
|
19
18
|
security_system.security_system_target_state.after_update do |security_system_target_state|
|
20
19
|
state = security_system_target_state_values[security_system_target_state]
|
@@ -24,11 +23,11 @@ security_system.security_system_target_state.after_update do |security_system_ta
|
|
24
23
|
end
|
25
24
|
|
26
25
|
security_system_current_state_values = {
|
27
|
-
0 =>
|
28
|
-
1 =>
|
29
|
-
2 =>
|
30
|
-
3 =>
|
31
|
-
4 =>
|
26
|
+
0 => "Stay Arm",
|
27
|
+
1 => "Away Arm",
|
28
|
+
2 => "Night Arm",
|
29
|
+
3 => "Disarmed",
|
30
|
+
4 => "Alarm Triggered"
|
32
31
|
}
|
33
32
|
security_system.security_system_current_state.after_update do |security_system_current_state|
|
34
33
|
state = security_system_current_state_values[security_system_current_state]
|
data/examples/smoke_sensor.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
smoke_sensor = RubyHome::ServiceFactory.create(:smoke_sensor,
|
@@ -7,8 +7,7 @@ smoke_sensor = RubyHome::ServiceFactory.create(:smoke_sensor,
|
|
7
7
|
status_low_battery: 0, # optional
|
8
8
|
status_tampered: 0, # optional
|
9
9
|
status_fault: 0, # optional
|
10
|
-
status_active: true # optional
|
11
|
-
)
|
10
|
+
status_active: true) # optional
|
12
11
|
|
13
12
|
smoke_sensor.smoke_detected.after_update do |smoke_detected|
|
14
13
|
if smoke_detected == 0
|
data/examples/switch.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
switch = RubyHome::ServiceFactory.create(:switch,
|
5
5
|
on: false, # required
|
6
|
-
name:
|
7
|
-
)
|
6
|
+
name: "switch") # optional
|
8
7
|
|
9
8
|
switch.on.after_update do |on|
|
10
9
|
if on
|
data/examples/television.rb
CHANGED
@@ -1,31 +1,29 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
RubyHome.configure do |c|
|
4
|
-
c.discovery_name =
|
4
|
+
c.discovery_name = "Television"
|
5
5
|
c.category_identifier = :television
|
6
6
|
end
|
7
7
|
|
8
8
|
accessory = RubyHome::Accessory.new
|
9
9
|
|
10
10
|
RubyHome::ServiceFactory.create(:accessory_information,
|
11
|
-
accessory: accessory
|
12
|
-
)
|
11
|
+
accessory: accessory) # required
|
13
12
|
|
14
13
|
television = RubyHome::ServiceFactory.create(:television,
|
15
14
|
accessory: accessory, # required
|
16
15
|
primary: true, # required
|
17
|
-
configured_name:
|
16
|
+
configured_name: "Television", # required
|
18
17
|
active: 1, # required
|
19
18
|
active_identifier: 1, # required
|
20
19
|
sleep_discovery_mode: 1, # required
|
21
20
|
remote_key: nil, # required
|
22
|
-
name:
|
21
|
+
name: "Television", # optional
|
23
22
|
power_mode_selection: true, # optional
|
24
23
|
picture_mode: 4, # optional
|
25
24
|
target_media_state: 0, # optional
|
26
25
|
current_media_state: 0, # optional
|
27
|
-
brightness: 100 # optional
|
28
|
-
)
|
26
|
+
brightness: 100) # optional
|
29
27
|
|
30
28
|
television.active.after_update do |active|
|
31
29
|
if active == 0
|
@@ -49,8 +47,7 @@ speaker = RubyHome::ServiceFactory.create(:television_speaker,
|
|
49
47
|
name: "Television Volume", # optional
|
50
48
|
active: 1, # optional
|
51
49
|
volume_control_type: 1, # optional
|
52
|
-
volume_selector: 0
|
53
|
-
)
|
50
|
+
volume_selector: 0) # optional
|
54
51
|
speaker.volume_selector.after_update do |volume|
|
55
52
|
if volume == 0
|
56
53
|
puts "television volume up"
|
@@ -69,9 +66,7 @@ sources = (1..4).map do |index|
|
|
69
66
|
is_configured: 1, # required
|
70
67
|
current_visibility_state: 0, # required
|
71
68
|
identifier: index, # optional
|
72
|
-
input_device_type: 1 # optional
|
73
|
-
|
74
|
-
)
|
69
|
+
input_device_type: 1) # optional
|
75
70
|
end
|
76
71
|
television.linked = [speaker] + sources
|
77
72
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
temperature_sensor = RubyHome::ServiceFactory.create(:temperature_sensor,
|
@@ -7,8 +7,7 @@ temperature_sensor = RubyHome::ServiceFactory.create(:temperature_sensor,
|
|
7
7
|
status_low_battery: 0, # optional
|
8
8
|
status_tampered: 0, # optional
|
9
9
|
status_fault: 0, # optional
|
10
|
-
status_active: true # optional
|
11
|
-
)
|
10
|
+
status_active: true) # optional
|
12
11
|
|
13
12
|
temperature_sensor.current_temperature.after_update do |current_temperature|
|
14
13
|
puts "temperature sensor current_temperature #{current_temperature}"
|
data/examples/thermostat.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
thermostat = RubyHome::ServiceFactory.create(:thermostat,
|
@@ -11,8 +11,7 @@ thermostat = RubyHome::ServiceFactory.create(:thermostat,
|
|
11
11
|
heating_threshold_temperature: 20, # optional
|
12
12
|
cooling_threshold_temperature: 10, # optional
|
13
13
|
target_relative_humidity: 0, # optional
|
14
|
-
current_relative_humidity: 0
|
15
|
-
)
|
14
|
+
current_relative_humidity: 0) # optional
|
16
15
|
|
17
16
|
thermostat.temperature_display_units.after_update do |temperature_display_unit|
|
18
17
|
if temperature_display_unit == 0
|
@@ -47,16 +46,16 @@ thermostat.current_temperature.after_update do |current_temperature|
|
|
47
46
|
end
|
48
47
|
|
49
48
|
target_heating_cooling_state_values = {
|
50
|
-
0 =>
|
51
|
-
1 =>
|
52
|
-
2 =>
|
53
|
-
3 =>
|
49
|
+
0 => "Off",
|
50
|
+
1 => "Heat",
|
51
|
+
2 => "Cool",
|
52
|
+
3 => "Auto"
|
54
53
|
}
|
55
54
|
thermostat.target_heating_cooling_state.after_update do |target_heating_cooling_state|
|
56
55
|
state = target_heating_cooling_state_values[target_heating_cooling_state]
|
57
56
|
puts "heater cooler target heating cooler state is #{state}"
|
58
57
|
|
59
|
-
return if thermostat.current_heating_cooling_state == target_heating_cooling_state
|
58
|
+
return true if thermostat.current_heating_cooling_state == target_heating_cooling_state
|
60
59
|
|
61
60
|
if target_heating_cooling_state == 1
|
62
61
|
thermostat.current_heating_cooling_state = 1
|
@@ -68,9 +67,9 @@ thermostat.target_heating_cooling_state.after_update do |target_heating_cooling_
|
|
68
67
|
end
|
69
68
|
|
70
69
|
current_heating_cooling_state_values = {
|
71
|
-
0 =>
|
72
|
-
1 =>
|
73
|
-
2 =>
|
70
|
+
0 => "Off",
|
71
|
+
1 => "Heat",
|
72
|
+
2 => "Cool"
|
74
73
|
}
|
75
74
|
thermostat.current_heating_cooling_state.after_update do |current_heating_cooling_state|
|
76
75
|
state = current_heating_cooling_state_values[current_heating_cooling_state]
|
data/examples/window.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
window = RubyHome::ServiceFactory.create(:window,
|
@@ -6,8 +6,7 @@ window = RubyHome::ServiceFactory.create(:window,
|
|
6
6
|
position_state: 1, # required
|
7
7
|
current_position: 0, # required
|
8
8
|
name: "window", # optional
|
9
|
-
obstruction_detected: false
|
10
|
-
)
|
9
|
+
obstruction_detected: false) # optional
|
11
10
|
|
12
11
|
window.target_position.after_update do |target_position|
|
13
12
|
puts "window target position #{target_position}"
|
@@ -25,9 +24,9 @@ window.target_position.after_update do |target_position|
|
|
25
24
|
end
|
26
25
|
|
27
26
|
position_state_values = {
|
28
|
-
0 =>
|
29
|
-
1 =>
|
30
|
-
2 =>
|
27
|
+
0 => "Decreasing",
|
28
|
+
1 => "Increasing",
|
29
|
+
2 => "Stopped"
|
31
30
|
}
|
32
31
|
window.position_state.after_update do |position_state|
|
33
32
|
state = position_state_values[position_state]
|
data/examples/window_covering.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "ruby_home"
|
2
2
|
|
3
3
|
accessory_information = RubyHome::ServiceFactory.create(:accessory_information)
|
4
4
|
window_covering = RubyHome::ServiceFactory.create(:window_covering,
|
@@ -10,8 +10,7 @@ window_covering = RubyHome::ServiceFactory.create(:window_covering,
|
|
10
10
|
current_vertical_tilt_angle: 0, # optional
|
11
11
|
target_vertical_tilt_angle: 0, # optional
|
12
12
|
current_horizontal_tilt_angle: 0, # optional
|
13
|
-
target_horizontal_tilt_angle: 0 # optional
|
14
|
-
)
|
13
|
+
target_horizontal_tilt_angle: 0) # optional
|
15
14
|
|
16
15
|
window_covering.target_position.after_update do |target_position|
|
17
16
|
puts "window covering target position #{target_position}"
|
@@ -29,9 +28,9 @@ window_covering.target_position.after_update do |target_position|
|
|
29
28
|
end
|
30
29
|
|
31
30
|
position_state_values = {
|
32
|
-
0 =>
|
33
|
-
1 =>
|
34
|
-
2 =>
|
31
|
+
0 => "Decreasing",
|
32
|
+
1 => "Increasing",
|
33
|
+
2 => "Stopped"
|
35
34
|
}
|
36
35
|
window_covering.position_state.after_update do |position_state|
|
37
36
|
state = position_state_values[position_state]
|
data/lib/ruby_home.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
1
|
+
require "dnssd"
|
2
|
+
require "facets/hash/slice"
|
3
|
+
require "hkdf"
|
4
|
+
require "oj"
|
5
|
+
require "rack"
|
6
|
+
require "rbnacl"
|
7
|
+
require "ruby_home/srp"
|
8
|
+
require "ruby_home/tlv"
|
9
|
+
require "securerandom"
|
10
|
+
require "sinatra/base"
|
11
|
+
require "socket"
|
12
|
+
require "webrick"
|
13
|
+
require "wisper"
|
14
|
+
require "yaml"
|
15
15
|
|
16
16
|
module RubyHome
|
17
17
|
[
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
"/ruby_home/hap/**/*.rb",
|
19
|
+
"/ruby_home/http/**/*.rb",
|
20
|
+
"/ruby_home/factories/**/*.rb",
|
21
|
+
"/ruby_home/dns/**/*.rb",
|
22
|
+
"/ruby_home/*.rb"
|
23
23
|
].each do |pattern|
|
24
24
|
Dir[File.dirname(__FILE__) + pattern].each { |file| require file }
|
25
25
|
end
|
@@ -36,8 +36,8 @@ module RubyHome
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def run
|
39
|
-
trap
|
40
|
-
trap
|
39
|
+
trap("INT") { shutdown }
|
40
|
+
trap("TERM") { shutdown }
|
41
41
|
|
42
42
|
greet
|
43
43
|
start
|