ruby_home 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1221aca521b00bdc16b4ce1f1e0b29c945899abcb7af5328ed13f6fce1d1f8a4
4
- data.tar.gz: 97ab21e599435d0c54e1b1f8e283a3edc245df3aca08e90c8f4dd639fb255fa8
3
+ metadata.gz: faee051d71617c37bbbaf0274d1469db94770d0623bc415a7f8448ff7ce4408b
4
+ data.tar.gz: c207e5bb1bec2c07d86183e912c21a3f8f4e8c3c4c27b639cd955a9a3d21b887
5
5
  SHA512:
6
- metadata.gz: 8d0ca7c92832e0a38ccf277ea2e025763efc519b2cfe83e47f0e58341d71c95c9062446e0769de147ad5f2bf93ee559677a904d24c23e3e3c4173b1cce74538c
7
- data.tar.gz: ee712b7ea54487917bef8a70e39268addf166f7c4cba696015dd09a28a4e634912f78b01ee56b0c4c4ccc26aa17be6f1f48c5d2ffab99c63311eb866b8990659
6
+ metadata.gz: 601d7ef1d41989e34ae7ba3a336dcf3b36c93a693a0bfb8d998afc2aae7e9bcf243c65406eab992269f03e627ef71f0b01be904969b37e063c2472f4b438a022
7
+ data.tar.gz: 7f5ee6ca44cabbdbf316e1a21c388ba09173e4a69853a8505d80249bd4602ee9f0cf609c8a6755fc6b6337c540d4a712573f1d4984b1435dd008ed04a77d8b49
@@ -0,0 +1,41 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ ubuntu:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: [3.0, 2.7, 2.6, 2.5]
15
+ steps:
16
+ - name: Install libdnssd
17
+ run: sudo apt-get install libavahi-compat-libdnssd-dev
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby ${{ matrix.ruby-version }}
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ - name: Install dependencies
24
+ run: bundle
25
+ - name: Run tests
26
+ run: bundle exec rake
27
+ mac:
28
+ runs-on: macos-latest
29
+ strategy:
30
+ matrix:
31
+ ruby-version: [3.0, 2.7, 2.6, 2.5]
32
+ steps:
33
+ - uses: actions/checkout@v2
34
+ - name: Set up Ruby ${{ matrix.ruby-version }}
35
+ uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby-version }}
38
+ - name: Install dependencies
39
+ run: bundle
40
+ - name: Run tests
41
+ run: bundle exec rake
@@ -0,0 +1,13 @@
1
+ # ruby_home Changelog
2
+
3
+ ## [v0.2.5](https://github.com/karlentwistle/ruby_home/releases/tag/v0.2.5) (2021-01-22)
4
+
5
+ ### Features
6
+
7
+ * Added support for television service and characteristics (#100, @johndbritton, @getowic)
8
+ * category_identifier can now be configured (#100, @getowic)
9
+
10
+
11
+ ### Fixes
12
+
13
+ * Fix Ruby 3.0 LoadError (#102, @karlentwistle)
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
  [![Maintainability](https://api.codeclimate.com/v1/badges/c81f4cfdf5c13d716487/maintainability)](https://codeclimate.com/github/karlentwistle/ruby_home/maintainability)
2
- [![Build Status](https://travis-ci.org/karlentwistle/ruby_home.svg?branch=master)](https://travis-ci.org/karlentwistle/ruby_home)
3
2
 
4
3
  # ruby_home
5
4
 
@@ -75,7 +74,7 @@ The following example services are available:
75
74
  - [Smoke sensor](https://github.com/karlentwistle/ruby_home/blob/master/examples/smoke_sensor.rb)
76
75
  - [Temperature sensor](https://github.com/karlentwistle/ruby_home/blob/master/examples/temperature_sensor.rb)
77
76
 
78
- ### Controlables
77
+ ### Controlables
79
78
  - [Air purifier](https://github.com/karlentwistle/ruby_home/blob/master/examples/air_purifier.rb)
80
79
  - [Battery service](https://github.com/karlentwistle/ruby_home/blob/master/examples/battery_service.rb)
81
80
  - [Door](https://github.com/karlentwistle/ruby_home/blob/master/examples/door.rb)
@@ -89,6 +88,7 @@ The following example services are available:
89
88
  - [Outlet](https://github.com/karlentwistle/ruby_home/blob/master/examples/outlet.rb)
90
89
  - [Security system](https://github.com/karlentwistle/ruby_home/blob/master/examples/security_system.rb)
91
90
  - [Switch](https://github.com/karlentwistle/ruby_home/blob/master/examples/switch.rb)
91
+ - [Television](https://github.com/karlentwistle/ruby_home/blob/master/examples/television.rb)
92
92
  - [Thermostat](https://github.com/karlentwistle/ruby_home/blob/master/examples/thermostat.rb)
93
93
  - [Window](https://github.com/karlentwistle/ruby_home/blob/master/examples/window.rb)
94
94
  - [Window covering](https://github.com/karlentwistle/ruby_home/blob/master/examples/window_covering.rb)
@@ -113,6 +113,7 @@ The following is the full list of available configuration options:
113
113
  | `password` | Used for pairing, must conform to the format XXX-XX-XXX where each X is a 0-9 digit and dashes are required | Randomly generated | `"101-48-005"` | String |
114
114
  | `host` | The hostname or IP address of the interface to listen on | `"0.0.0.0"` | `"192.168.0.2"` | String |
115
115
  | `port` | The port that should be used when starting the built-in web server | `4567` | `8080` | Integer |
116
+ | `category_identifier` | Indicates the [category](https://github.com/karlentwistle/ruby_home/blob/master/lib/ruby_home/config/categories.yml) that best describes the primary function of the accessory. | `:bridge` | `:fan` | Symbol |
116
117
 
117
118
  ## Customization
118
119
 
@@ -126,7 +127,8 @@ accessory_information = RubyHome::ServiceFactory.create(:accessory_information,
126
127
  manufacturer: 'Fake Company',
127
128
  model: 'BSB001',
128
129
  name: 'Kickass fan bridge',
129
- serial_number: 'AB1-UK-A123456'
130
+ serial_number: 'AB1-UK-A123456',
131
+ category_identifier: :fan
130
132
  )
131
133
 
132
134
  fan = RubyHome::ServiceFactory.create(:fan,
@@ -0,0 +1,78 @@
1
+ require 'ruby_home'
2
+
3
+ RubyHome.configure do |c|
4
+ c.discovery_name = 'Television'
5
+ c.category_identifier = :television
6
+ end
7
+
8
+ accessory = RubyHome::Accessory.new
9
+
10
+ RubyHome::ServiceFactory.create(:accessory_information,
11
+ accessory: accessory, # required
12
+ )
13
+
14
+ television = RubyHome::ServiceFactory.create(:television,
15
+ accessory: accessory, # required
16
+ primary: true, # required
17
+ configured_name: 'Television', # required
18
+ active: 1, # required
19
+ active_identifier: 1, # required
20
+ sleep_discovery_mode: 1, # required
21
+ remote_key: nil, # required
22
+ name: 'Television', # optional
23
+ power_mode_selection: true, # optional
24
+ picture_mode: 4, # optional
25
+ target_media_state: 0, # optional
26
+ current_media_state: 0, # optional
27
+ brightness: 100 # optional
28
+ )
29
+
30
+ television.active.after_update do |active|
31
+ if active == 0
32
+ puts "television is inactive"
33
+ else
34
+ puts "television is active"
35
+ end
36
+ end
37
+
38
+ television.active_identifier.after_update do |active_identifier|
39
+ puts "television active input source #{active_identifier}"
40
+ end
41
+
42
+ television.remote_key.after_update do |remote_key|
43
+ puts "television remote_key #{remote_key}"
44
+ end
45
+
46
+ speaker = RubyHome::ServiceFactory.create(:television_speaker,
47
+ accessory: accessory, # required
48
+ mute: false, # required
49
+ name: "Television Volume", # optional
50
+ active: 1, # optional
51
+ volume_control_type: 1, # optional
52
+ volume_selector: 0, # optional
53
+ )
54
+ speaker.volume_selector.after_update do |volume|
55
+ if volume == 0
56
+ puts "television volume up"
57
+ else
58
+ puts "television volume down"
59
+ end
60
+ end
61
+
62
+ sources = (1..4).map do |index|
63
+ RubyHome::ServiceFactory.create(:input_source,
64
+ accessory: accessory, # required
65
+ subtype: "source#{index}", # required
66
+ name: "Source #{index}", # required
67
+ configured_name: "Source #{index}", # required
68
+ input_source_type: 3, # required
69
+ is_configured: 1, # required
70
+ current_visibility_state: 0, # required
71
+ identifier: index, # optional
72
+ input_device_type: 1 # optional
73
+
74
+ )
75
+ end
76
+ television.linked = [speaker] + sources
77
+
78
+ RubyHome.run
@@ -25,13 +25,14 @@ module RubyHome
25
25
  'write' => 'pw',
26
26
  }.freeze
27
27
 
28
- def initialize(uuid:, name:, description:, format:, unit:, properties:, service: , value_object: )
28
+ def initialize(uuid:, name:, description:, format:, unit:, properties:, constraints:, service: , value_object: )
29
29
  @uuid = uuid
30
30
  @name = name
31
31
  @description = description
32
32
  @format = format
33
33
  @unit = unit
34
34
  @properties = properties
35
+ @constraints = constraints
35
36
  @service = service
36
37
  @value_object = value_object
37
38
  end
@@ -44,6 +45,7 @@ module RubyHome
44
45
  :format,
45
46
  :unit,
46
47
  :properties,
48
+ :constraints,
47
49
  :instance_id,
48
50
  :value_object,
49
51
  )
@@ -66,6 +68,10 @@ module RubyHome
66
68
  service.instance_id
67
69
  end
68
70
 
71
+ def valid_values
72
+ constraints.fetch('ValidValues', {}).keys.map(&:to_i)
73
+ end
74
+
69
75
  def method_missing(method_name, *args, &block)
70
76
  value.send(method_name, *args, &block)
71
77
  end
@@ -0,0 +1,39 @@
1
+ ---
2
+ :other: 1
3
+ :bridge: 2
4
+ :fan: 3
5
+ :garage_door_opener: 4
6
+ :lightbulb: 5
7
+ :door_lock: 6
8
+ :outlet: 7
9
+ :switch: 8
10
+ :thermostat: 9
11
+ :sensor: 10
12
+ :alarm_system: 11
13
+ :security_system: 11
14
+ :door: 12
15
+ :window: 13
16
+ :window_covering: 14
17
+ :programmable_switch: 15
18
+ :range_extender: 16
19
+ :camera: 17
20
+ :ip_camera: 17
21
+ :video_doorbell: 18
22
+ :air_purifier: 19
23
+ :air_heater: 20
24
+ :air_conditioner: 21
25
+ :air_humidifier: 22
26
+ :air_dehumidifier: 23
27
+ :apple_tv: 24
28
+ :homepod: 25
29
+ :speaker: 26
30
+ :airport: 27
31
+ :sprinkler: 28
32
+ :faucet: 29
33
+ :shower_head: 30
34
+ :television: 31
35
+ :target_controller: 32
36
+ :router: 33
37
+ :audio_receiver: 34
38
+ :tv_set_top_box: 35
39
+ :tv_streaming_stick: 36
@@ -30,6 +30,18 @@
30
30
  ValidValues:
31
31
  '0': Inactive
32
32
  '1': Active
33
+ - :name: :active_identifier
34
+ :description: Active Identifier
35
+ :uuid: 000000E7-0000-1000-8000-0026BB765291
36
+ :format: uint32
37
+ :unit: nil
38
+ :permissions:
39
+ - securedRead
40
+ :properties:
41
+ - read
42
+ - write
43
+ - cnotify
44
+ :constraints:
33
45
  - :name: :administrator_only_access
34
46
  :description: Administrator Only Access
35
47
  :uuid: 00000001-0000-1000-8000-0026BB765291
@@ -241,6 +253,23 @@
241
253
  '0': Not Charging
242
254
  '1': Charging
243
255
  '2': Not Chargeable
256
+ - :name: :closed_captions
257
+ :description: Closed Captions
258
+ :uuid: 000000DD-0000-1000-8000-0026BB765291
259
+ :format: uint8
260
+ :unit: nil
261
+ :permissions:
262
+ - securedRead
263
+ :properties:
264
+ - read
265
+ - write
266
+ - cnotify
267
+ :constraints:
268
+ MaximumValue: 1
269
+ MinimumValue: 0
270
+ ValidValues:
271
+ '0': Disabled
272
+ '1': Enabled
244
273
  - :name: :color_temperature
245
274
  :description: Color Temperature
246
275
  :uuid: 000000CE-0000-1000-8000-0026BB765291
@@ -258,6 +287,18 @@
258
287
  MaximumValue: 500
259
288
  MinimumValue: 140
260
289
  StepValue: 1
290
+ - :name: :configured_name
291
+ :description: Configured Name
292
+ :uuid: 000000E3-0000-1000-8000-0026BB765291
293
+ :format: string
294
+ :unit: nil
295
+ :permissions:
296
+ - securedRead
297
+ :properties:
298
+ - read
299
+ - write
300
+ - cnotify
301
+ :constraints:
261
302
  - :name: :contact_sensor_state
262
303
  :description: Contact Sensor State
263
304
  :uuid: 0000006A-0000-1000-8000-0026BB765291
@@ -419,6 +460,26 @@
419
460
  '1': Idle
420
461
  '2': Humidifying
421
462
  '3': Dehumidifying
463
+ - :name: :current_media_state
464
+ :description: Current Media State
465
+ :uuid: 000000E0-0000-1000-8000-0026BB765291
466
+ :format: uint8
467
+ :unit: nil
468
+ :permissions:
469
+ - securedRead
470
+ :properties:
471
+ - read
472
+ - cnotify
473
+ :constraints:
474
+ MaximumValue: 5
475
+ MinimumValue: 0
476
+ ValidValues:
477
+ '0': Play
478
+ '1': Pause
479
+ '2': Stop
480
+ '3':
481
+ '4': Loading
482
+ '5': Interrupted
422
483
  - :name: :current_position
423
484
  :description: Current Position
424
485
  :uuid: 0000006D-0000-1000-8000-0026BB765291
@@ -510,6 +571,24 @@
510
571
  MaximumValue: 90
511
572
  MinimumValue: -90
512
573
  StepValue: 1
574
+ - :name: :current_visibility_state
575
+ :description: Current Visibility State
576
+ :uuid: 00000135-0000-1000-8000-0026BB765291
577
+ :format: uint8
578
+ :unit: nil
579
+ :permissions:
580
+ - securedRead
581
+ :properties:
582
+ - read
583
+ - cnotify
584
+ :constraints:
585
+ MaximumValue: 3
586
+ MinimumValue: 0
587
+ ValidValues:
588
+ '0': Shown
589
+ '1': Hidden
590
+ '2':
591
+ '3':
513
592
  - :name: :digital_zoom
514
593
  :description: Digital Zoom
515
594
  :uuid: 0000011D-0000-1000-8000-0026BB765291
@@ -524,6 +603,18 @@
524
603
  - cnotify
525
604
  - uncnotify
526
605
  :constraints:
606
+ - :name: :display_order
607
+ :description: Display Order
608
+ :uuid: 00000136-0000-1000-8000-0026BB765291
609
+ :format: tlv8
610
+ :unit: nil
611
+ :permissions:
612
+ - securedRead
613
+ :properties:
614
+ - read
615
+ - write
616
+ - cnotify
617
+ :constraints:
527
618
  - :name: :filter_change_indication
528
619
  :description: Filter Change Indication
529
620
  :uuid: 000000AC-0000-1000-8000-0026BB765291
@@ -618,6 +709,18 @@
618
709
  MaximumValue: 360
619
710
  MinimumValue: 0
620
711
  StepValue: 1
712
+ - :name: :identifier
713
+ :description: Identifier
714
+ :uuid: 000000E6-0000-1000-8000-0026BB765291
715
+ :format: uint32
716
+ :unit: nil
717
+ :permissions:
718
+ - securedRead
719
+ :properties:
720
+ - read
721
+ :constraints:
722
+ MinimumValue: 0
723
+ StepValue: 1
621
724
  - :name: :identify
622
725
  :description: Identify
623
726
  :uuid: 00000014-0000-1000-8000-0026BB765291
@@ -674,6 +777,52 @@
674
777
  ValidValues:
675
778
  '0': Not in use
676
779
  '1': In use
780
+ - :name: :input_device_type
781
+ :description: Input Device Type
782
+ :uuid: 000000DC-0000-1000-8000-0026BB765291
783
+ :format: uint8
784
+ :unit: nil
785
+ :permissions:
786
+ - securedRead
787
+ :properties:
788
+ - read
789
+ - cnotify
790
+ :constraints:
791
+ MaximumValue: 6
792
+ MinimumValue: 0
793
+ ValidValues:
794
+ '0': Other
795
+ '1': Television
796
+ '2': Recording
797
+ '3': Tuner
798
+ '4': Playback
799
+ '5': Audio System
800
+ '6':
801
+ - :name: :input_source_type
802
+ :description: Input Source Type
803
+ :uuid: 000000DB-0000-1000-8000-0026BB765291
804
+ :format: uint8
805
+ :unit: nil
806
+ :permissions:
807
+ - securedRead
808
+ :properties:
809
+ - read
810
+ - cnotify
811
+ :constraints:
812
+ MaximumValue: 10
813
+ MinimumValue: 0
814
+ ValidValues:
815
+ '0': Other
816
+ '1': Home Screen
817
+ '2': Tuner
818
+ '3': HDMI
819
+ '4': Composite Video
820
+ '5': S Video
821
+ '6': Component Video
822
+ '7': DVI
823
+ '8': Airplay
824
+ '9': USB
825
+ '10': Application
677
826
  - :name: :is_configured
678
827
  :description: Is Configured
679
828
  :uuid: 000000D6-0000-1000-8000-0026BB765291
@@ -1028,6 +1177,35 @@
1028
1177
  - read
1029
1178
  - write
1030
1179
  :constraints:
1180
+ - :name: :picture_mode
1181
+ :description: Picture Mode
1182
+ :uuid: 000000E2-0000-1000-8000-0026BB765291
1183
+ :format: uint8
1184
+ :unit: nil
1185
+ :permissions:
1186
+ - securedRead
1187
+ :properties:
1188
+ - read
1189
+ - write
1190
+ - cnotify
1191
+ :constraints:
1192
+ MaximumValue: 13
1193
+ MinimumValue: 0
1194
+ ValidValues:
1195
+ '0': Other
1196
+ '1': Standard
1197
+ '2': Calibrated
1198
+ '3': Calibrated Dark
1199
+ '4': Vivid
1200
+ '5': Game
1201
+ '6': Computer
1202
+ '7': Custom
1203
+ '8':
1204
+ '9':
1205
+ '10':
1206
+ '11':
1207
+ '12':
1208
+ '13':
1031
1209
  - :name: :pm10_density
1032
1210
  :description: PM10 Density
1033
1211
  :uuid: 000000C7-0000-1000-8000-0026BB765291
@@ -1074,6 +1252,21 @@
1074
1252
  '0': Decreasing
1075
1253
  '1': Increasing
1076
1254
  '2': Stopped
1255
+ - :name: :power_mode_selection
1256
+ :description: Power Mode Selection
1257
+ :uuid: 000000DF-0000-1000-8000-0026BB765291
1258
+ :format: uint8
1259
+ :unit: nil
1260
+ :permissions:
1261
+ - securedRead
1262
+ :properties:
1263
+ - write
1264
+ :constraints:
1265
+ MaximumValue: 1
1266
+ MinimumValue: 0
1267
+ ValidValues:
1268
+ '0': Show
1269
+ '1': Hide
1077
1270
  - :name: :program_mode
1078
1271
  :description: Program Mode
1079
1272
  :uuid: 000000D1-0000-1000-8000-0026BB765291
@@ -1155,6 +1348,36 @@
1155
1348
  MaximumValue: 3600
1156
1349
  MinimumValue: 0
1157
1350
  StepValue: 1
1351
+ - :name: :remote_key
1352
+ :description: Remote Key
1353
+ :uuid: 000000E1-0000-1000-8000-0026BB765291
1354
+ :format: uint8
1355
+ :unit: nil
1356
+ :permissions:
1357
+ - securedRead
1358
+ :properties:
1359
+ - write
1360
+ :constraints:
1361
+ MaximumValue: 16
1362
+ MinimumValue: 0
1363
+ ValidValues:
1364
+ '0': Rewind
1365
+ '1': Fast Forward
1366
+ '2': Next Track
1367
+ '3': Previous Track
1368
+ '4': Arrow Up
1369
+ '5': Arrow Down
1370
+ '6': Arrow Left
1371
+ '7': Arrow Right
1372
+ '8': Select
1373
+ '9': Back
1374
+ '10': Exit
1375
+ '11': Play Pause
1376
+ '12':
1377
+ '13':
1378
+ '14':
1379
+ '15': Information
1380
+ '16':
1158
1381
  - :name: :reset_filter_indication
1159
1382
  :description: Reset Filter Indication
1160
1383
  :uuid: 000000AD-0000-1000-8000-0026BB765291
@@ -1362,6 +1585,22 @@
1362
1585
  ValidValues:
1363
1586
  '0': Horizontal
1364
1587
  '1': Vertical
1588
+ - :name: :sleep_discovery_mode
1589
+ :description: Sleep Discovery Mode
1590
+ :uuid: 000000E8-0000-1000-8000-0026BB765291
1591
+ :format: uint8
1592
+ :unit: nil
1593
+ :permissions:
1594
+ - securedRead
1595
+ :properties:
1596
+ - read
1597
+ - cnotify
1598
+ :constraints:
1599
+ MaximumValue: 1
1600
+ MinimumValue: 0
1601
+ ValidValues:
1602
+ '0': Not Discoverable
1603
+ '1': Always Discoverable
1365
1604
  - :name: :smoke_detected
1366
1605
  :description: Smoke Detected
1367
1606
  :uuid: 00000076-0000-1000-8000-0026BB765291
@@ -1664,6 +1903,24 @@
1664
1903
  '0': Humidifier or Dehumidifier
1665
1904
  '1': Humidifier
1666
1905
  '2': Dehumidifier
1906
+ - :name: :target_media_state
1907
+ :description: Target Media State
1908
+ :uuid: 00000137-0000-1000-8000-0026BB765291
1909
+ :format: uint8
1910
+ :unit: nil
1911
+ :permissions:
1912
+ - securedRead
1913
+ :properties:
1914
+ - read
1915
+ - write
1916
+ - cnotify
1917
+ :constraints:
1918
+ MaximumValue: 2
1919
+ MinimumValue: 0
1920
+ ValidValues:
1921
+ '0': Play
1922
+ '1': Pause
1923
+ '2': Stop
1667
1924
  - :name: :target_position
1668
1925
  :description: Target Position
1669
1926
  :uuid: 0000007C-0000-1000-8000-0026BB765291
@@ -1766,6 +2023,23 @@
1766
2023
  MaximumValue: 90
1767
2024
  MinimumValue: -90
1768
2025
  StepValue: 1
2026
+ - :name: :target_visibility_state
2027
+ :description: Target Visibility State
2028
+ :uuid: 00000134-0000-1000-8000-0026BB765291
2029
+ :format: uint8
2030
+ :unit: nil
2031
+ :permissions:
2032
+ - securedRead
2033
+ :properties:
2034
+ - read
2035
+ - write
2036
+ - cnotify
2037
+ :constraints:
2038
+ MaximumValue: 1
2039
+ MinimumValue: 0
2040
+ ValidValues:
2041
+ '0': Shown
2042
+ '1': Hidden
1769
2043
  - :name: :temperature_display_units
1770
2044
  :description: Temperature Display Units
1771
2045
  :uuid: 00000036-0000-1000-8000-0026BB765291
@@ -1845,6 +2119,39 @@
1845
2119
  MaximumValue: 100
1846
2120
  MinimumValue: 0
1847
2121
  StepValue: 1
2122
+ - :name: :volume_control_type
2123
+ :description: Volume Control Type
2124
+ :uuid: 000000E9-0000-1000-8000-0026BB765291
2125
+ :format: uint8
2126
+ :unit: nil
2127
+ :permissions:
2128
+ - securedRead
2129
+ :properties:
2130
+ - read
2131
+ - cnotify
2132
+ :constraints:
2133
+ MaximumValue: 3
2134
+ MinimumValue: 0
2135
+ ValidValues:
2136
+ '0': None
2137
+ '1': Relative
2138
+ '2': Relative with Current
2139
+ '3': Absolute
2140
+ - :name: :volume_selector
2141
+ :description: Volume Selector
2142
+ :uuid: 000000EA-0000-1000-8000-0026BB765291
2143
+ :format: uint8
2144
+ :unit: nil
2145
+ :permissions:
2146
+ - securedRead
2147
+ :properties:
2148
+ - write
2149
+ :constraints:
2150
+ MaximumValue: 1
2151
+ MinimumValue: 0
2152
+ ValidValues:
2153
+ '0': Increment
2154
+ '1': Decrement
1848
2155
  - :name: :water_level
1849
2156
  :description: Water Level
1850
2157
  :uuid: 000000B5-0000-1000-8000-0026BB765291
@@ -214,6 +214,19 @@
214
214
  - 00000023-0000-1000-8000-0026BB765291
215
215
  :required_characteristics_uuids:
216
216
  - 00000010-0000-1000-8000-0026BB765291
217
+ - :name: :input_source
218
+ :description: Input Source
219
+ :uuid: 000000D9-0000-1000-8000-0026BB765291
220
+ :optional_characteristics_uuids:
221
+ - 000000E6-0000-1000-8000-0026BB765291
222
+ - 000000DC-0000-1000-8000-0026BB765291
223
+ - 00000134-0000-1000-8000-0026BB765291
224
+ :required_characteristics_uuids:
225
+ - 000000E3-0000-1000-8000-0026BB765291
226
+ - 000000DB-0000-1000-8000-0026BB765291
227
+ - 000000D6-0000-1000-8000-0026BB765291
228
+ - 00000023-0000-1000-8000-0026BB765291
229
+ - 00000135-0000-1000-8000-0026BB765291
217
230
  - :name: :irrigation_system
218
231
  :description: Irrigation System
219
232
  :uuid: 000000CF-0000-1000-8000-0026BB765291
@@ -382,6 +395,34 @@
382
395
  - 00000023-0000-1000-8000-0026BB765291
383
396
  :required_characteristics_uuids:
384
397
  - 00000025-0000-1000-8000-0026BB765291
398
+ - :name: :television
399
+ :description: Television
400
+ :uuid: '000000D8-0000-1000-8000-0026BB765291'
401
+ :optional_characteristics_uuids:
402
+ - 00000008-0000-1000-8000-0026BB765291
403
+ - 000000DD-0000-1000-8000-0026BB765291
404
+ - 00000136-0000-1000-8000-0026BB765291
405
+ - 000000E0-0000-1000-8000-0026BB765291
406
+ - 00000137-0000-1000-8000-0026BB765291
407
+ - 000000E2-0000-1000-8000-0026BB765291
408
+ - 000000DF-0000-1000-8000-0026BB765291
409
+ - 00000023-0000-1000-8000-0026BB765291
410
+ :required_characteristics_uuids:
411
+ - 000000B0-0000-1000-8000-0026BB765291
412
+ - 000000E7-0000-1000-8000-0026BB765291
413
+ - 000000E3-0000-1000-8000-0026BB765291
414
+ - 000000E1-0000-1000-8000-0026BB765291
415
+ - 000000E8-0000-1000-8000-0026BB765291
416
+ - :name: :television_speaker
417
+ :description: Television Speaker
418
+ :uuid: 00000113-0000-1000-8000-0026BB765291
419
+ :optional_characteristics_uuids:
420
+ - 000000B0-0000-1000-8000-0026BB765291
421
+ - 00000119-0000-1000-8000-0026BB765291
422
+ - 000000E9-0000-1000-8000-0026BB765291
423
+ - 000000EA-0000-1000-8000-0026BB765291
424
+ :required_characteristics_uuids:
425
+ - 0000011A-0000-1000-8000-0026BB765291
385
426
  - :name: :temperature_sensor
386
427
  :description: Temperature Sensor
387
428
  :uuid: '0000008A-0000-1000-8000-0026BB765291'
@@ -1,7 +1,12 @@
1
1
  module RubyHome
2
+ class UnknownCategoriyIdentifierError < StandardError; end
3
+
2
4
  class Configuration
3
5
  extend Forwardable
4
6
 
7
+ CATEGORIES_FILEPATH = (File.dirname(__FILE__) + '/config/categories.yml').freeze
8
+ CATEGORIES = YAML.load_file(CATEGORIES_FILEPATH).freeze
9
+
5
10
  def initialize(accessory_info = AccessoryInfo.instance)
6
11
  @accessory_info = accessory_info
7
12
  end
@@ -11,6 +16,7 @@ module RubyHome
11
16
  DEFAULT_PORT = 4567
12
17
  DEFAULT_MODEL_NAME = DEFAULT_NAME
13
18
  DEFAULT_DISCOVERY_NAME = DEFAULT_NAME
19
+ DEFAULT_CATEGORY_IDENTIFIER = 2
14
20
 
15
21
  def discovery_name
16
22
  @discovery_name || DEFAULT_DISCOVERY_NAME
@@ -28,6 +34,19 @@ module RubyHome
28
34
  @host || DEFAULT_HOST
29
35
  end
30
36
 
37
+ def category_identifier
38
+ @category_identifier || DEFAULT_CATEGORY_IDENTIFIER
39
+ end
40
+
41
+ def category_identifier=(value)
42
+ if value.is_a?(Symbol)
43
+ raise UnknownCategoriyIdentifierError if !CATEGORIES.include?(value)
44
+ @category_identifier = CATEGORIES[value]
45
+ else
46
+ @category_identifier = value.to_i
47
+ end
48
+ end
49
+
31
50
  attr_writer :discovery_name, :model_name, :host, :port
32
51
 
33
52
  def_delegators :@accessory_info, :password, :password=
@@ -38,7 +38,7 @@ module RubyHome
38
38
  # 1-65535.
39
39
 
40
40
  def accessory_category_identifier
41
- 2
41
+ @configuration.category_identifier
42
42
  end
43
43
 
44
44
  # Feature flags (e.g. "0x3" for bits 0 and 1). Required if non-zero.
@@ -15,6 +15,7 @@ module RubyHome
15
15
  format: template.format,
16
16
  name: characteristic_name,
17
17
  properties: template.properties,
18
+ constraints: template.constraints,
18
19
  service: service,
19
20
  unit: template.unit,
20
21
  uuid: template.uuid,
@@ -14,13 +14,13 @@ module RubyHome
14
14
  'perms' => perms(characteristic),
15
15
  'format' => characteristic.format,
16
16
  'description' => characteristic.description,
17
- }.merge(value_hash(characteristic))
17
+ }
18
+ .merge(value_hash(characteristic))
19
+ .merge(valid_values_hash(characteristic))
18
20
  end
19
21
 
20
22
  private
21
23
 
22
- HIDDEN_VALUE_OBJECTS = [ IdentifyValue ].freeze
23
-
24
24
  def perms(characteristic)
25
25
  characteristic.properties.map do |property|
26
26
  RubyHome::Characteristic::PROPERTIES[property]
@@ -28,10 +28,18 @@ module RubyHome
28
28
  end
29
29
 
30
30
  def value_hash(characteristic)
31
- if HIDDEN_VALUE_OBJECTS.include?(characteristic.value_object.class)
31
+ if characteristic.properties.include?('read')
32
+ { 'value' => characteristic.value }
33
+ else
34
+ {}
35
+ end
36
+ end
37
+
38
+ def valid_values_hash(characteristic)
39
+ if characteristic.valid_values.empty?
32
40
  {}
33
41
  else
34
- { 'value' => characteristic.value }.compact
42
+ { 'valid-values' => characteristic.valid_values }
35
43
  end
36
44
  end
37
45
  end
@@ -15,7 +15,17 @@ module RubyHome
15
15
  'characteristics' => CharacteristicSerializer.new(service.characteristics).serializable_hash,
16
16
  'primary' => service.primary,
17
17
  'hidden' => service.hidden,
18
- }
18
+ }.merge(linked_services(service))
19
+ end
20
+
21
+ private
22
+
23
+ def linked_services(service)
24
+ if service.linked.empty?
25
+ {}
26
+ else
27
+ { 'linked' => service.linked.map(&:instance_id) }
28
+ end
19
29
  end
20
30
  end
21
31
  end
@@ -23,9 +23,11 @@ module RubyHome
23
23
  end
24
24
 
25
25
  def read
26
- return false unless File.exists?(source)
26
+ return false unless File.exist?(source)
27
27
 
28
28
  YAML.load_file(source)
29
+ rescue Errno::EBADF
30
+ return false
29
31
  end
30
32
  end
31
33
 
@@ -12,6 +12,7 @@ module RubyHome
12
12
  @description = description
13
13
  @uuid = uuid
14
14
  @characteristics = CharacteristicCollection.new
15
+ @linked = []
15
16
  end
16
17
 
17
18
  attr_reader(
@@ -24,6 +25,8 @@ module RubyHome
24
25
  :uuid,
25
26
  :instance_id
26
27
  )
28
+
29
+ attr_accessor :linked
27
30
 
28
31
  def instance_id=(new_id)
29
32
  raise DuplicateServiceError if accessory.contains_instance_id?(new_id)
@@ -1,3 +1,3 @@
1
1
  module RubyHome
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
@@ -24,16 +24,17 @@ Gem::Specification.new do |spec|
24
24
  spec.bindir = 'bin'
25
25
  spec.executables = ['ruby_home']
26
26
  spec.require_paths = ['lib']
27
- spec.required_ruby_version = '>= 2.4.1'
27
+ spec.required_ruby_version = '>= 2.5.0'
28
28
 
29
29
  spec.add_dependency 'dnssd', '~> 3.0'
30
30
  spec.add_dependency 'facets', '~> 3.1'
31
31
  spec.add_dependency 'hkdf', '~> 0.3.0'
32
- spec.add_dependency 'oj', '3.10.5'
32
+ spec.add_dependency 'oj', '~> 3.10'
33
33
  spec.add_dependency 'rbnacl', '~> 7.0'
34
34
  spec.add_dependency 'ruby_home-srp', '~> 1.3'
35
- spec.add_dependency 'ruby_home-tlv', '~> 0.1.0'
36
- spec.add_dependency 'sinatra', '2.0.8.1'
35
+ spec.add_dependency 'ruby_home-tlv', '~> 0.1'
36
+ spec.add_dependency 'sinatra', '~> 2.0'
37
+ spec.add_dependency 'webrick', '~> 1.7'
37
38
  spec.add_dependency 'wisper', '~> 2.0'
38
39
 
39
40
  spec.add_development_dependency 'byebug', '~> 11.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_home
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Entwistle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-05 00:00:00.000000000 Z
11
+ date: 2021-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dnssd
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: oj
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.10.5
61
+ version: '3.10'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.10.5
68
+ version: '3.10'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rbnacl
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -100,28 +100,42 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.1.0
103
+ version: '0.1'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.1.0
110
+ version: '0.1'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sinatra
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '='
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 2.0.8.1
117
+ version: '2.0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '='
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webrick
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.7'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: 2.0.8.1
138
+ version: '1.7'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: wisper
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -218,11 +232,12 @@ executables:
218
232
  extensions: []
219
233
  extra_rdoc_files: []
220
234
  files:
235
+ - ".github/workflows/tests.yml"
221
236
  - ".gitignore"
222
237
  - ".hound.yml"
223
238
  - ".rspec"
224
239
  - ".rubocop.yml"
225
- - ".travis.yml"
240
+ - CHANGELOG.md
226
241
  - Gemfile
227
242
  - LICENSE
228
243
  - README.md
@@ -253,6 +268,7 @@ files:
253
268
  - examples/security_system.rb
254
269
  - examples/smoke_sensor.rb
255
270
  - examples/switch.rb
271
+ - examples/television.rb
256
272
  - examples/temperature_sensor.rb
257
273
  - examples/thermostat.rb
258
274
  - examples/window.rb
@@ -263,6 +279,7 @@ files:
263
279
  - lib/ruby_home/accessory_info.rb
264
280
  - lib/ruby_home/characteristic.rb
265
281
  - lib/ruby_home/characteristic_collection.rb
282
+ - lib/ruby_home/config/categories.yml
266
283
  - lib/ruby_home/config/characteristics.yml
267
284
  - lib/ruby_home/config/services.yml
268
285
  - lib/ruby_home/configuration.rb
@@ -335,14 +352,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
335
352
  requirements:
336
353
  - - ">="
337
354
  - !ruby/object:Gem::Version
338
- version: 2.4.1
355
+ version: 2.5.0
339
356
  required_rubygems_version: !ruby/object:Gem::Requirement
340
357
  requirements:
341
358
  - - ">="
342
359
  - !ruby/object:Gem::Version
343
360
  version: '0'
344
361
  requirements: []
345
- rubygems_version: 3.0.3
362
+ rubygems_version: 3.1.4
346
363
  signing_key:
347
364
  specification_version: 4
348
365
  summary: Ruby HomeKit support
@@ -1,31 +0,0 @@
1
- dist: xenial
2
- cache: bundler
3
- language: ruby
4
- before_install:
5
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y software-properties-common; fi
6
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php; fi
7
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update; fi
8
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libsodium-dev; fi
9
- - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; fi
10
- - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install libsodium; fi
11
- install:
12
- - 'gem update --system'
13
- - 'gem --version'
14
- - 'gem install bundler -v 2.0.1'
15
- - 'bundle --version'
16
- - bundle
17
- rvm:
18
- - 2.4
19
- - 2.5
20
- - 2.6
21
- - 2.7
22
- - ruby-head
23
- os:
24
- - linux
25
- - osx
26
- addons:
27
- apt:
28
- packages:
29
- - libavahi-compat-libdnssd-dev
30
- notifications:
31
- email: false