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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/home_assistant/ble.rb +12 -18
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e962366e242a811c1629e3d1b6b31f8cf091df6f
4
- data.tar.gz: 2d4f69d0681cfecf051518f5ee7e67b7946a699a
3
+ metadata.gz: 41ac6003838b2dbd9aa2dd47f0e0b6ae37f5e582
4
+ data.tar.gz: 9d9d85e7ff4f5e0acfce610409b311d063fd94fd
5
5
  SHA512:
6
- metadata.gz: a354881a9191742f2a63da85031fb8e50139d6bafb46ad370fa67d5a10854257475013dff7987f94346be9d853b234741a66451869a2c04c6df6f575f559258e
7
- data.tar.gz: 460e4979e32733a61a6d9321c15e9e91c781482c8de60850bd309f130a3b78fd6dee6078653548786b951f00c5b7d2b33bf03af6e5be4861c3ef484ca096c190
6
+ metadata.gz: 5932ff84754b1e518886b3ae12d0a34fc57fe24c1d8c5469519a62a81e1e3e931a21e2c386852adfadec807b7425dfada266ca1d1b3b7a360d3171a140373243
7
+ data.tar.gz: '089d9ab7c88ae419daea1fc3cfeff26ab2097d7b8e870c63ae49c7706d5b3dbd1d4988ddfc92deb5ac28834473f32b9c3ef549e0392fc9dbeaefd09a7a1b6b81'
@@ -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
- discover
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 detect_new_devices
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 discover
134
- debug 'Cleaning old devices'
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.pre.alpha.pre.26
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: 1.3.1
134
+ version: '0'
135
135
  requirements: []
136
136
  rubyforge_project:
137
- rubygems_version: 2.4.5
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