home_assistant-ble 1.1.0.pre.alpha.pre.19 → 1.1.0.pre.alpha.pre.20

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: 92234e3757b5a7b183c12a60bab97a3fe31587f8
4
- data.tar.gz: 28089416f66609837843ac6012539f9cef672274
3
+ metadata.gz: 567820a2750982cf752c4563b8bdaa51480e2519
4
+ data.tar.gz: a1b64acff4bae209d87e3cc4f582e6c92880e138
5
5
  SHA512:
6
- metadata.gz: a23b1a3054e716d912750d7d3b54bec940b49b6a57e9e07bcd8eb6a0cf1c06a5bb3a0b6400cd3ed45ef5c7ec9b3ff0da736d5c65a50ee717a6f83ec90ed69efa
7
- data.tar.gz: be698b77c1af501ddcae6a7153957ebe804fc8e032066de3b85697649b35efe2523b1368555d0f52ea4848dc15e0b3c6056588c96a7d250c1466e9521f854b7b
6
+ metadata.gz: 0ab5c0f51ff8a307ac57bb592a90b8fea61ef8bd3e43e02ad19afe893eac1cdea1841aa2de055b167ea763b281dadce1098d1ad21ede0f2c31de37c95e58529a
7
+ data.tar.gz: 8fd24882f68393a0ed73e0b4317700daf1a70d6a2f5763a1f2bc7bbc758d836fd32284c0d314fad2d439fc6fe4bb8b9aa88f82c9f559ee3307de71264a998f15
data/.rubocop.yml CHANGED
@@ -4,6 +4,9 @@ Metrics/LineLength:
4
4
  Metrics/MethodLength:
5
5
  Max: 20
6
6
 
7
+ Metrics/ClassLength:
8
+ Max: 200
9
+
7
10
  Style/Documentation:
8
11
  Enabled: false
9
12
 
data/README.md CHANGED
@@ -35,12 +35,12 @@ sudo setcap 'cap_net_raw,cap_net_admin+eip' `readlink -f \`which ruby\``
35
35
  ### Configuration
36
36
 
37
37
  ```
38
- interval: 30 # in seconds, interval between device scan
39
- grace_period: 60 # in seconds, delay before considering a device has disappeared
40
- home_assistant_url: http://localhost:8123 # url to contact home-assistant
41
- home_assistant_password: xxxxx # non mandatory password to authenticate to home-assistant api
42
- home_assistant_devices: # devices whose activity will be sent to home-assistant.
38
+ interval: 30 # in seconds, interval between device scan. Defaults to 30
39
+ grace_period: 60 # in seconds, delay before considering a device has disappeared. Defaults to 60
40
+ home_assistant_url: http://localhost:8123 # url to contact home-assistant. Defaults to http://localhost:8123
41
+ home_assistant_password: xxxxx # non mandatory password to authenticate to home-assistant api. Default is nil
42
+ home_assistant_devices: # devices whose activity will be sent to home-assistant. Default is empty (no tracked devices)
43
43
  F0:5C:F4:EA:BF:C8: nut1 # [macaddress]: [identifier for home-assistant]
44
- ```
45
44
 
46
- All presented settings (except `home_assistant_devices`) are set to their _default_ values. They don't need to be set.
45
+ home_assistant_devices_file: /var/lib/hass/known_devices.yaml # read devices whose activity will be sent to home-assistant. Default is empty (devices from home-assistant are not tracked). This can easily replace home_assistant_devices setting.
46
+ ```
data/example_config.yml CHANGED
@@ -3,4 +3,5 @@ grace_period: 60 # in seconds
3
3
  home_assistant_url: http://localhost:8123
4
4
  # home_assistant_password: xxxxx
5
5
  home_assistant_devices:
6
- F0:5C:F4:EA:BF:C8: nut1
6
+ F0:5C:F4:EA:BE:C1: a_device
7
+ home_assistant_devices_file: /var/lib/hass/known_devices.yaml
@@ -7,6 +7,7 @@ After=network.target
7
7
  #Group=hass
8
8
 
9
9
  Environment=RUBYOPT="-w0"
10
+ Environment=DEBUG=true
10
11
  ExecStart=/usr/bin/home_assistant-ble /var/lib/hass/ble.yml
11
12
 
12
13
  [Install]
@@ -35,8 +35,17 @@ module HomeAssistant
35
35
  end
36
36
 
37
37
  def home_assistant_devices
38
- # TODO: read this from HA known_devices.yml
39
- config['home_assistant_devices'] || {}
38
+ devices = {}
39
+ if config['home_assistant_devices_file']
40
+ YAML.load_file(config['home_assistant_devices_file']).each do |name, conf|
41
+ next unless conf['mac'] =~ /^(ble_|bt_)/i
42
+ next unless conf['track']
43
+ mac = conf['mac'].gsub(/^(ble_|bt_)/i, '').upcase
44
+ devices[mac] = name
45
+ debug "Adding #{mac} (#{name}) found in known_devices.yaml"
46
+ end
47
+ end
48
+ devices.merge!(config['home_assistant_devices']) if config['home_assistant_devices']
40
49
  end
41
50
 
42
51
  def run
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.1.0.pre.alpha.pre.19
4
+ version: 1.1.0.pre.alpha.pre.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grégoire Seux