home_assistant-ble 1.0.0.pre.alpha.pre.10 → 1.0.0.pre.alpha.pre.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fabf4c43e9222f9afd0e074b55608d252cd73cc
4
- data.tar.gz: 753272e22fe5f04dcd36e7c186b19edab471a0c4
3
+ metadata.gz: f4db3623100d5b5d6b072a87f6d963bb30fcf240
4
+ data.tar.gz: 4611ae90eb9695db6082b23754883ac1dcc87b49
5
5
  SHA512:
6
- metadata.gz: 7989fe95c35629f845412d788abbdb22715acf4c18229f5f15b7d24c51b0aec9c105f17a46dfbc743972275414b7e2c8534f5e8b4d10e4a14825f07f4faa830f
7
- data.tar.gz: c793083615f779165237cbfb6b1b8d22d9b4d8ef392dedc2f72df4980a04531b319464992d17a0b2c78ed5470a8515b7f5ec70d5d7084da083f4e5627cdf01c1
6
+ metadata.gz: bcbc08493c1a95264c157a98540b0e8393bf335eb1209d1fe7eaa9b03d9a7569c7b1edd92652e8218369ce6ee0a2a4ce46a89f2cd4b050a0ddf0bd84d557cd72
7
+ data.tar.gz: f71b43e9f8af0c3a9850af23d62fc093a1537cef941c678810207e33938955d5584743a469ce7d4430eac2d3f5a72d59d1a33bbb174b30cbc49618144ce3638d
data/README.md CHANGED
@@ -18,6 +18,13 @@ Run `home_assistant-ble [your config file]` binary.
18
18
 
19
19
  More instruction to launch this as a service with systemd (TODO).
20
20
 
21
+ To be able to run with a non-root user, read http://unix.stackexchange.com/questions/96106/bluetooth-le-scan-as-non-root. In short (adapt if using a non-debian distribution):
22
+
23
+ ```
24
+ sudo apt install libcap2-bin
25
+ sudo setcap 'cap_net_raw,cap_net_admin+eip' `readlink -f \`which ruby\``
26
+ ```
27
+
21
28
  ## Configuration
22
29
 
23
30
  ```
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = 'home_assistant-ble'
8
8
  spec.version = HomeAssistant::Ble::VERSION
9
9
  spec.version = "#{spec.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
10
- spec.version = ENV['TRAVIS_TAG'] unless ENV['TRAVIS_TAG'].empty?
10
+ spec.version = ENV['TRAVIS_TAG'] if ENV['TRAVIS_TAG'] && !ENV['TRAVIS_TAG'].empty?
11
11
  spec.authors = ['Grégoire Seux']
12
12
  spec.email = ['grego_homeassistant@familleseux.net']
13
13
 
@@ -56,8 +56,9 @@ module HomeAssistant
56
56
  def debug(message)
57
57
  log 'Set DEBUG environment variable to activate debug logs' unless ENV['DEBUG'] || @debug_tip
58
58
  @debug_tip = true
59
+ return unless ENV['DEBUG']
59
60
  print '(debug) '
60
- puts message if ENV['DEBUG']
61
+ puts message
61
62
  end
62
63
 
63
64
  def detect_devices
@@ -106,6 +107,7 @@ module HomeAssistant
106
107
 
107
108
  def adapter
108
109
  @adapter ||= begin
110
+ ensure_rights!
109
111
  iface = BLE::Adapter.list.first
110
112
  debug "Selecting #{iface} to listen for bluetooth events"
111
113
  raise 'Unable to find a bluetooth device' unless iface
@@ -115,6 +117,14 @@ module HomeAssistant
115
117
  end
116
118
  end
117
119
  end
120
+
121
+ def ensure_rights!
122
+ BLE::Adapter.list.first
123
+ rescue DBus::Error => e
124
+ raise unless e.message =~ /DBus.Error.AccessDenied/
125
+ log 'Not enough rights to use bluetooth device, read https://github.com/kamaradclimber/home_assistant-ble'
126
+ exit 1
127
+ end
118
128
  end
119
129
  end
120
130
  end
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.0.0.pre.alpha.pre.10
4
+ version: 1.0.0.pre.alpha.pre.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grégoire Seux