home_assistant-ble 1.2.0.pre.alpha.pre.26 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/home_assistant/ble.rb +12 -18
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41ac6003838b2dbd9aa2dd47f0e0b6ae37f5e582
|
4
|
+
data.tar.gz: 9d9d85e7ff4f5e0acfce610409b311d063fd94fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5932ff84754b1e518886b3ae12d0a34fc57fe24c1d8c5469519a62a81e1e3e931a21e2c386852adfadec807b7425dfada266ca1d1b3b7a360d3171a140373243
|
7
|
+
data.tar.gz: '089d9ab7c88ae419daea1fc3cfeff26ab2097d7b8e870c63ae49c7706d5b3dbd1d4988ddfc92deb5ac28834473f32b9c3ef549e0392fc9dbeaefd09a7a1b6b81'
|
data/lib/home_assistant/ble.rb
CHANGED
@@ -16,10 +16,6 @@ module HomeAssistant
|
|
16
16
|
@known_devices = {}
|
17
17
|
end
|
18
18
|
|
19
|
-
def discovery_time
|
20
|
-
config['discovery_time'] || 60
|
21
|
-
end
|
22
|
-
|
23
19
|
# polling interval
|
24
20
|
def interval
|
25
21
|
config['interval'] || 30
|
@@ -54,9 +50,9 @@ module HomeAssistant
|
|
54
50
|
|
55
51
|
def run
|
56
52
|
loop do
|
57
|
-
|
58
|
-
detect_new_devices
|
53
|
+
detect_devices
|
59
54
|
clean_devices
|
55
|
+
release_adapter
|
60
56
|
debug "Will sleep #{interval}s before relisting devices"
|
61
57
|
sleep interval
|
62
58
|
end
|
@@ -76,7 +72,7 @@ module HomeAssistant
|
|
76
72
|
puts message
|
77
73
|
end
|
78
74
|
|
79
|
-
def
|
75
|
+
def detect_devices
|
80
76
|
adapter.devices.each do |name|
|
81
77
|
unless known_devices.key?(name)
|
82
78
|
log "Just discovered #{name}"
|
@@ -126,20 +122,18 @@ module HomeAssistant
|
|
126
122
|
iface = BLE::Adapter.list.first
|
127
123
|
debug "Selecting #{iface} to listen for bluetooth events"
|
128
124
|
raise 'Unable to find a bluetooth device' unless iface
|
129
|
-
BLE::Adapter.new(iface)
|
125
|
+
BLE::Adapter.new(iface).tap do |a|
|
126
|
+
debug 'Activating discovery'
|
127
|
+
a.start_discovery
|
128
|
+
debug 'Sleeping a bit to discover devices'
|
129
|
+
sleep 20
|
130
|
+
a.stop_discovery
|
131
|
+
end
|
130
132
|
end
|
131
133
|
end
|
132
134
|
|
133
|
-
def
|
134
|
-
|
135
|
-
adapter.devices.dup.each do |d|
|
136
|
-
adapter[d].remove
|
137
|
-
end
|
138
|
-
debug 'Activating discovery'
|
139
|
-
adapter.start_discovery
|
140
|
-
debug 'Sleeping a bit to discover devices'
|
141
|
-
sleep discovery_time
|
142
|
-
adapter.stop_discovery
|
135
|
+
def release_adapter
|
136
|
+
@adapter = nil
|
143
137
|
end
|
144
138
|
|
145
139
|
def ensure_rights!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: home_assistant-ble
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grégoire Seux
|
@@ -129,12 +129,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
|
-
- - "
|
132
|
+
- - ">="
|
133
133
|
- !ruby/object:Gem::Version
|
134
|
-
version:
|
134
|
+
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.6.8
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Companion app for home-assistant sending event about BLE devices
|