ledenet_api 1.4.1 → 1.4.2

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: 899df804f239c23c90e1e13d71e2f91f95873ece
4
- data.tar.gz: 92e0e57c1dc0c4a09469c12bdc94a0093645692e
3
+ metadata.gz: 1e5e8d4f413e19ff927524214a21ebca92d355cc
4
+ data.tar.gz: b6dc2f96936668a01e67d60aff2e563df065d89e
5
5
  SHA512:
6
- metadata.gz: 1cef2986a4cb6c2aafd8c187a2fd9d02a54e333de1b34d628a513b62088c89936a220880b2af7ae7bf8e871167e98a67544681a34ee0c03a7b5991b70bf6cacf
7
- data.tar.gz: 7566d9b24c17e14af7d510589ff006c75d930e65ea38f5ba0df3e31709703c6fe706341506c03512396012d910dade92525c6875e4ffeccba104730bf8f9f14e
6
+ metadata.gz: 60b9a5f1d845bacb6a282f0d8042783a999a260bdb50b91136b29dd45f593b35c8d9262e1754b06285fce171142fd8add6830be9f2eb91afda10d70ba7f4c741
7
+ data.tar.gz: 3f93c82424f55dc7fe237c30150d25e5223d6f5c61564be352ab8a6ab344b658016fce8022dd5888eb2926056fe965e9edff7cfc410c7d308efeb1112d60b546
data/README.md CHANGED
@@ -61,15 +61,15 @@ $ ledenet-ufo --list
61
61
  #### Get current status
62
62
 
63
63
  ```
64
- $ ledenet-ufo -s
65
- {"red":"255","green":"255","blue":"255","warm_white":"255","is_on":true}
64
+ $ ledenet-ufo --status
65
+ {"is_on":true,"red":"255","green":"255","blue":"255","warm_white":"255","running_function?":false,"speed":61,"speed_packet_value":"12","function_name":"NO_FUNCTION","function_id":"97"}
66
66
  ```
67
67
 
68
68
  #### Turn on, adjust colors
69
69
 
70
70
  ```
71
71
  $ ledenet-ufo --on -r 200 -g 0 -b 255 --warm-white 0 --status
72
- {"red":"200","green":"0","blue":"255","warm_white":"255","is_on":true}
72
+ {"is_on":true,"red":"200","green":"0","blue":"255","warm_white":"0","running_function?":false,"speed":99,"speed_packet_value":"0","function_name":"NO_FUNCTION","function_id":"97"}
73
73
  ```
74
74
 
75
75
  #### Turn off
@@ -81,7 +81,8 @@ $ ledenet-ufo --off
81
81
  #### Set function
82
82
 
83
83
  ```
84
- $ ledenet-ufo --function seven_color_cross_fade --speed 10
84
+ $ ledenet-ufo --speed 60 --function seven_color_cross_fade --status
85
+ {"is_on":true,"red":"255","green":"0","blue":"0","warm_white":"255","running_function?":true,"speed":61,"speed_packet_value":"12","function_name":"SEVEN_COLOR_CROSS_FADE","function_id":"37"}
85
86
  ```
86
87
 
87
88
  ### Ruby API
@@ -180,12 +181,13 @@ LEDENET::Functions.all_functions
180
181
  ```
181
182
 
182
183
  ```ruby
183
- fn = LEDENET::Functions::SEVEN_COLOR_CROSS_FADE
184
- speed = 0 # very slow
184
+ api.update_function(:seven_color_cross_fade)
185
+ api.update_function_speed(100) #very fast
185
186
 
186
- api.update_function(fn, speed)
187
-
188
- api.update_function(:blue_green_cross_fade, 100) # Very fast
187
+ api.update_function_data(
188
+ function_id: LEDENET::Functions::BLUE_GREEN_CROSS_FADE,
189
+ speed: 50
190
+ )
189
191
  ```
190
192
 
191
193
  To quit the function and return to a constant color, simply update a color value:
@@ -106,7 +106,7 @@ begin
106
106
  row_format = "%16s %18s %20s\n"
107
107
  printf row_format, "IP ADDRESS", "HW ADDRESS", "Model #"
108
108
 
109
- LEDENET.discover_devices.each do |device|
109
+ devices.each do |device|
110
110
  formatted_hwaddr = (0...12).step(2)
111
111
  .map { |x| device.hw_addr[x, 2] }
112
112
  .join(':')
@@ -119,7 +119,9 @@ begin
119
119
  if options[:ip]
120
120
  ip = options[:ip]
121
121
  elsif options[:hw_addr]
122
- r = LEDENET.discover_devices.select { |x| x.hw_addr == options[:hw_addr] }
122
+ r = LEDENET.discover_devices(expected_hw_addrs: [options[:hw_addr]])
123
+ r.select! { |x| x.hw_addr == options[:hw_addr] }
124
+
123
125
  if r.empty?
124
126
  raise "Couldn't find device with mac addr: #{options[:hw_addr]}"
125
127
  end
@@ -19,6 +19,7 @@ module LEDENET
19
19
  expected_devices: 1,
20
20
  timeout: 5,
21
21
  expected_models: [],
22
+ expected_hw_addrs: [],
22
23
  udp_port: 48899
23
24
  }
24
25
 
@@ -39,12 +40,17 @@ module LEDENET
39
40
 
40
41
  discovered_devices = []
41
42
  discovered_models = Set.new
43
+ discovered_hw_addrs = Set.new
42
44
  expected_models = Set.new(options[:expected_models])
45
+ expected_hw_addrs = Set.new(
46
+ options[:expected_hw_addrs].map { |x| x.gsub(':', '').upcase }
47
+ )
43
48
 
44
49
  begin
45
50
  Timeout::timeout(options[:timeout]) do
46
- while discovered_devices.count < options[:expected_devices] or
47
- !expected_models.subset?(discovered_models)
51
+ while discovered_devices.count < options[:expected_devices] ||
52
+ !expected_models.subset?(discovered_models) ||
53
+ !expected_hw_addrs.subset?(discovered_hw_addrs)
48
54
  data = send_socket.recv(1024)
49
55
 
50
56
  device = LEDENET::Device.new(data)
@@ -52,6 +58,7 @@ module LEDENET
52
58
  if device.ip and device.hw_addr and device.model
53
59
  discovered_devices.push(device)
54
60
  discovered_models.add(device.model)
61
+ discovered_hw_addrs.add(device.hw_addr)
55
62
  end
56
63
  end
57
64
  end
@@ -1,3 +1,3 @@
1
1
  module LEDENET
2
- VERSION = '1.4.1'
2
+ VERSION = '1.4.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ledenet_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Mullins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-01 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata