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/lib/ruby_home/service.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "service_collection"
|
2
2
|
|
3
3
|
module RubyHome
|
4
4
|
class DuplicateServiceError < StandardError; end
|
5
5
|
|
6
6
|
class Service
|
7
|
-
def initialize(accessory
|
7
|
+
def initialize(accessory:, name:, description:, uuid:, primary: false, hidden: false)
|
8
8
|
@accessory = accessory
|
9
9
|
@primary = primary
|
10
10
|
@hidden = hidden
|
@@ -25,7 +25,7 @@ module RubyHome
|
|
25
25
|
:uuid,
|
26
26
|
:instance_id
|
27
27
|
)
|
28
|
-
|
28
|
+
|
29
29
|
attr_accessor :linked
|
30
30
|
|
31
31
|
def instance_id=(new_id)
|
data/lib/ruby_home/version.rb
CHANGED
data/rubyhome.gemspec
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
3
|
+
require "ruby_home/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
6
|
+
spec.name = "ruby_home"
|
7
|
+
spec.version = RubyHome::VERSION
|
8
|
+
spec.authors = ["Karl Entwistle"]
|
9
|
+
spec.email = ["karl@entwistle.com"]
|
10
|
+
spec.summary = "Ruby HomeKit support"
|
11
|
+
spec.description = <<~DESCRIPTION
|
13
12
|
RubyHome is a lightweight service you can run on your home network that
|
14
13
|
emulates the iOS HomeKit API. It supports community contributed plugins, which
|
15
14
|
are modules that provide a bridge from HomeKit to various 3rd-party APIs
|
16
15
|
provided by manufacturers of smart home devices.
|
17
16
|
DESCRIPTION
|
18
|
-
spec.homepage
|
19
|
-
spec.license
|
17
|
+
spec.homepage = "https://github.com/karlentwistle/ruby_home"
|
18
|
+
spec.license = "MIT"
|
20
19
|
|
21
|
-
spec.files
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
22
21
|
f.match(%r{^(test|spec|features)/})
|
23
22
|
end
|
24
|
-
spec.bindir
|
25
|
-
spec.executables
|
26
|
-
spec.require_paths = [
|
27
|
-
spec.required_ruby_version =
|
23
|
+
spec.bindir = "bin"
|
24
|
+
spec.executables = ["ruby_home"]
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
spec.required_ruby_version = ">= 2.5.0"
|
28
27
|
|
29
|
-
spec.add_dependency
|
30
|
-
spec.add_dependency
|
31
|
-
spec.add_dependency
|
32
|
-
spec.add_dependency
|
33
|
-
spec.add_dependency
|
34
|
-
spec.add_dependency
|
35
|
-
spec.add_dependency
|
36
|
-
spec.add_dependency
|
37
|
-
spec.add_dependency
|
38
|
-
spec.add_dependency
|
28
|
+
spec.add_dependency "dnssd", "~> 3.0"
|
29
|
+
spec.add_dependency "facets", "~> 3.1"
|
30
|
+
spec.add_dependency "hkdf", "~> 1.0.0"
|
31
|
+
spec.add_dependency "oj", "~> 3.10"
|
32
|
+
spec.add_dependency "rbnacl", "~> 7.0"
|
33
|
+
spec.add_dependency "ruby_home-srp", "~> 1.3"
|
34
|
+
spec.add_dependency "ruby_home-tlv", "~> 0.1"
|
35
|
+
spec.add_dependency "sinatra", "~> 2.0"
|
36
|
+
spec.add_dependency "webrick", "~> 1.7"
|
37
|
+
spec.add_dependency "wisper", "~> 2.0"
|
39
38
|
|
40
|
-
spec.add_development_dependency
|
41
|
-
spec.add_development_dependency
|
42
|
-
spec.add_development_dependency
|
43
|
-
spec.add_development_dependency
|
44
|
-
spec.add_development_dependency
|
39
|
+
spec.add_development_dependency "byebug", "~> 11.0"
|
40
|
+
spec.add_development_dependency "plist", "~> 3.4"
|
41
|
+
spec.add_development_dependency "rack-test", "~> 1.1.0"
|
42
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
43
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
44
|
+
spec.add_development_dependency "standard", "~> 1.0"
|
45
45
|
end
|
@@ -1,39 +1,39 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "byebug"
|
4
|
+
require "plist"
|
5
|
+
require "yaml"
|
6
6
|
|
7
7
|
module RubyHome
|
8
8
|
class CharacteristicGenerator
|
9
9
|
class << self
|
10
10
|
def run
|
11
11
|
convert_binary_plist
|
12
|
-
File.open(file_path,
|
12
|
+
File.open(file_path, "w") do |file|
|
13
13
|
file.write generate_characteristics.to_yaml
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def generate_characteristics
|
18
|
-
parsed_xml[
|
18
|
+
parsed_xml["Characteristics"].map do |characteristics_xml|
|
19
19
|
new(characteristics_xml).generate_characteristic_hash
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def convert_binary_plist
|
24
24
|
system([
|
25
|
-
|
26
|
-
|
25
|
+
"plutil -convert xml1 -o",
|
26
|
+
"/tmp/Accessory.xml",
|
27
27
|
"\'/Applications/Utilities/HomeKit\ Accessory\ Simulator.app/Contents/Frameworks/HAPAccessoryKit.framework/Versions/A/Resources/default.metadata.plist\'"
|
28
|
-
].join(
|
28
|
+
].join(" "))
|
29
29
|
end
|
30
30
|
|
31
31
|
def parsed_xml
|
32
|
-
Plist.parse_xml(
|
32
|
+
Plist.parse_xml("/tmp/Accessory.xml")
|
33
33
|
end
|
34
34
|
|
35
35
|
def file_path
|
36
|
-
File.dirname(__FILE__) +
|
36
|
+
File.dirname(__FILE__) + "/../lib/ruby_home/config/characteristics.yml"
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -41,7 +41,6 @@ module RubyHome
|
|
41
41
|
@constraints = xml["Constraints"]
|
42
42
|
@format = xml["Format"]
|
43
43
|
@name = xml["Name"]
|
44
|
-
@permissions = xml["Permissions"]
|
45
44
|
@properties = xml["Properties"]
|
46
45
|
@uuid = xml["UUID"]
|
47
46
|
@unit = xml["Unit"]
|
@@ -54,29 +53,28 @@ module RubyHome
|
|
54
53
|
uuid: uuid,
|
55
54
|
format: format,
|
56
55
|
unit: sanitized_unit,
|
57
|
-
permissions: permissions,
|
58
56
|
properties: properties,
|
59
|
-
constraints: constraints
|
57
|
+
constraints: constraints
|
60
58
|
}
|
61
59
|
end
|
62
60
|
|
63
61
|
private
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
def sanitized_name
|
64
|
+
name.downcase.tr(" ", "_").tr(".", "_")
|
65
|
+
end
|
68
66
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
67
|
+
def sanitized_unit
|
68
|
+
if unit
|
69
|
+
"\"#{unit}\""
|
70
|
+
else
|
71
|
+
"nil"
|
75
72
|
end
|
73
|
+
end
|
76
74
|
|
77
|
-
|
75
|
+
private
|
78
76
|
|
79
|
-
|
77
|
+
attr_reader :constraints, :format, :name, :properties, :uuid, :unit
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
data/sbin/service_generator.rb
CHANGED
@@ -1,46 +1,47 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "byebug"
|
4
|
+
require "plist"
|
5
|
+
require "yaml"
|
6
|
+
require_relative "../lib/ruby_home"
|
6
7
|
|
7
8
|
module RubyHome
|
8
9
|
class ServiceGenerator
|
9
10
|
class << self
|
10
11
|
def run
|
11
12
|
convert_binary_plist
|
12
|
-
File.open(file_path,
|
13
|
+
File.open(file_path, "w") do |file|
|
13
14
|
file.write generate_services.to_yaml
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
18
|
def generate_services
|
18
|
-
parsed_xml[
|
19
|
+
parsed_xml["Services"].map do |services_xml|
|
19
20
|
new(services_xml).generate_service_hash
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
24
|
def convert_binary_plist
|
24
25
|
system([
|
25
|
-
|
26
|
-
|
26
|
+
"plutil -convert xml1 -o",
|
27
|
+
"/tmp/Accessory.xml",
|
27
28
|
"\'/Applications/Utilities/HomeKit\ Accessory\ Simulator.app/Contents/Frameworks/HAPAccessoryKit.framework/Versions/A/Resources/default.metadata.plist\'"
|
28
|
-
].join(
|
29
|
+
].join(" "))
|
29
30
|
end
|
30
31
|
|
31
32
|
def parsed_xml
|
32
|
-
Plist.parse_xml(
|
33
|
+
Plist.parse_xml("/tmp/Accessory.xml")
|
33
34
|
end
|
34
35
|
|
35
36
|
def file_path
|
36
|
-
File.dirname(__FILE__) +
|
37
|
+
File.dirname(__FILE__) + "/../lib/ruby_home/config/services.yml"
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
def initialize(xml)
|
41
42
|
@name = xml["Name"]
|
42
|
-
@
|
43
|
-
@
|
43
|
+
@optional_characteristic_uuids = xml["OptionalCharacteristics"]
|
44
|
+
@required_characteristic_uuids = xml["RequiredCharacteristics"]
|
44
45
|
@uuid = xml["UUID"]
|
45
46
|
end
|
46
47
|
|
@@ -49,30 +50,38 @@ module RubyHome
|
|
49
50
|
name: sanitized_name.to_sym,
|
50
51
|
description: name,
|
51
52
|
uuid: uuid,
|
52
|
-
|
53
|
-
|
53
|
+
optional_characteristic_names: optional_characteristic_names.sort,
|
54
|
+
required_characteristic_names: required_characteristic_names.sort
|
54
55
|
}
|
55
56
|
end
|
56
57
|
|
57
58
|
private
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
def sanitized_name
|
61
|
+
name.downcase.tr(" ", "_")
|
62
|
+
end
|
62
63
|
|
63
|
-
|
64
|
+
def optional_characteristic_names
|
65
|
+
optional_characteristic_uuids.map do |uuid|
|
66
|
+
RubyHome::CharacteristicTemplate.find_by(uuid: uuid).name
|
67
|
+
end + additional_optional_characteristic_names
|
68
|
+
end
|
64
69
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
ADDITIONAL_OPTIONAL_CHARACTERISTIC_NAMES = {
|
71
|
+
"lightbulb" => [:color_temperature]
|
72
|
+
}.freeze
|
73
|
+
|
74
|
+
def additional_optional_characteristic_names
|
75
|
+
ADDITIONAL_OPTIONAL_CHARACTERISTIC_NAMES.fetch(sanitized_name, [])
|
76
|
+
end
|
77
|
+
|
78
|
+
def required_characteristic_names
|
79
|
+
required_characteristic_uuids.map do |uuid|
|
80
|
+
RubyHome::CharacteristicTemplate.find_by(uuid: uuid).name
|
73
81
|
end
|
82
|
+
end
|
74
83
|
|
75
|
-
|
84
|
+
attr_reader :name, :required_characteristic_uuids, :optional_characteristic_uuids, :uuid
|
76
85
|
end
|
77
86
|
end
|
78
87
|
|
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
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karl Entwistle
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dnssd
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 1.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 1.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: oj
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +220,20 @@ dependencies:
|
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '3.0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: standard
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - "~>"
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '1.0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - "~>"
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '1.0'
|
223
237
|
description: |
|
224
238
|
RubyHome is a lightweight service you can run on your home network that
|
225
239
|
emulates the iOS HomeKit API. It supports community contributed plugins, which
|
@@ -237,6 +251,7 @@ files:
|
|
237
251
|
- ".hound.yml"
|
238
252
|
- ".rspec"
|
239
253
|
- ".rubocop.yml"
|
254
|
+
- ".standard.yml"
|
240
255
|
- CHANGELOG.md
|
241
256
|
- Gemfile
|
242
257
|
- LICENSE
|
@@ -281,6 +296,8 @@ files:
|
|
281
296
|
- lib/ruby_home/characteristic_collection.rb
|
282
297
|
- lib/ruby_home/config/categories.yml
|
283
298
|
- lib/ruby_home/config/characteristics.yml
|
299
|
+
- lib/ruby_home/config/manual_characteristics.yml
|
300
|
+
- lib/ruby_home/config/manual_services.yml
|
284
301
|
- lib/ruby_home/config/services.yml
|
285
302
|
- lib/ruby_home/configuration.rb
|
286
303
|
- lib/ruby_home/device_id.rb
|
@@ -344,7 +361,7 @@ homepage: https://github.com/karlentwistle/ruby_home
|
|
344
361
|
licenses:
|
345
362
|
- MIT
|
346
363
|
metadata: {}
|
347
|
-
post_install_message:
|
364
|
+
post_install_message:
|
348
365
|
rdoc_options: []
|
349
366
|
require_paths:
|
350
367
|
- lib
|
@@ -359,8 +376,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
359
376
|
- !ruby/object:Gem::Version
|
360
377
|
version: '0'
|
361
378
|
requirements: []
|
362
|
-
rubygems_version: 3.
|
363
|
-
signing_key:
|
379
|
+
rubygems_version: 3.2.15
|
380
|
+
signing_key:
|
364
381
|
specification_version: 4
|
365
382
|
summary: Ruby HomeKit support
|
366
383
|
test_files: []
|