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 +4 -4
- data/README.md +7 -0
- data/home_assistant-ble.gemspec +1 -1
- data/lib/home_assistant/ble.rb +11 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4db3623100d5b5d6b072a87f6d963bb30fcf240
|
4
|
+
data.tar.gz: 4611ae90eb9695db6082b23754883ac1dcc87b49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
```
|
data/home_assistant-ble.gemspec
CHANGED
@@ -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']
|
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
|
|
data/lib/home_assistant/ble.rb
CHANGED
@@ -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
|
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
|