ledenet_api 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +60 -4
- data/bin/ledenet-ufo +8 -3
- data/lib/ledenet/version.rb +1 -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: 9b2322ff3b2b79724713e5b7b620a1f3d160fc61
|
4
|
+
data.tar.gz: 0313e482fccc8cd041f2440f802220e50d1151f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5088d200d263359d2846de07822c1d3dbbc4f98fac1482677264d5c86dd28629127ccfebba560fc530fe1898d2a8f1ccf33db2dccaccdff365b484995d31c54
|
7
|
+
data.tar.gz: f942c29bb3e5a98f945f1b9c258b46547300834687f2c0bacff6c497f1492a9ea35c5d0a41ae462c5a3374c1ec9be3c65230c8ddd58047f37dee4a20c121941b
|
data/README.md
CHANGED
@@ -22,7 +22,63 @@ gem 'ledenet_api'
|
|
22
22
|
|
23
23
|
## Using it
|
24
24
|
|
25
|
-
|
25
|
+
In addition to the Ruby API, this gem also comes bundled with an executable named `ledenet-ufo`.
|
26
|
+
|
27
|
+
### Commandline
|
28
|
+
|
29
|
+
Here's the `--help` message:
|
30
|
+
|
31
|
+
```
|
32
|
+
$ ledenet-ufo
|
33
|
+
Usage: ledenet-ufo --list
|
34
|
+
OR: ledenet-ufo [IP|HW ADDR] [OPTIONS]
|
35
|
+
|
36
|
+
-r, --red [VALUE] Set red to VALUE
|
37
|
+
-g, --green [VALUE] Set green to VALUE
|
38
|
+
-b, --blue [VALUE] Set blue to VALUE
|
39
|
+
-w, --warm-white [VALUE] Set warm white to VALUE
|
40
|
+
--on Turn on the controller
|
41
|
+
--off Turn off the controller
|
42
|
+
-l, --list Prints a list of available devices and exists
|
43
|
+
-s, --status Prints status as JSON
|
44
|
+
-h, --help Prints this help message
|
45
|
+
```
|
46
|
+
|
47
|
+
When using it, you can specify the IP address, hardware (mac) address, or let `ledenet_api` choose an arbitrary device on the local network (this would work well if you only have one).
|
48
|
+
|
49
|
+
Examples:
|
50
|
+
|
51
|
+
#### List available devices
|
52
|
+
|
53
|
+
```
|
54
|
+
$ ledenet-ufo --list
|
55
|
+
IP ADDRESS HW ADDRESS Model #
|
56
|
+
10.133.8.113 XXXXXXXXXXXX HF-LPB100-ZJ200
|
57
|
+
```
|
58
|
+
|
59
|
+
#### Get current status
|
60
|
+
|
61
|
+
```
|
62
|
+
$ ledenet-ufo -s
|
63
|
+
{"red":"255","green":"255","blue":"255","warm_white":"255","is_on":true}
|
64
|
+
```
|
65
|
+
|
66
|
+
#### Turn on, adjust colors
|
67
|
+
|
68
|
+
```
|
69
|
+
$ ledenet-ufo --on -r 200 -g 0 -b 255 --warm-white 0 --status
|
70
|
+
{"red":"200","green":"0","blue":"255","warm_white":"255","is_on":true}
|
71
|
+
```
|
72
|
+
|
73
|
+
#### Turn off
|
74
|
+
|
75
|
+
```
|
76
|
+
$ ledenet-ufo --off
|
77
|
+
```
|
78
|
+
|
79
|
+
### Ruby API
|
80
|
+
|
81
|
+
#### Device discovery
|
26
82
|
|
27
83
|
These devices implement a service discovery protocol, which allows you to find them on your network without digging for their IP address. To use it:
|
28
84
|
|
@@ -41,7 +97,7 @@ irb(main):005:0> LEDENET.discover_devices(expected_devices: 2, timeout: 1)
|
|
41
97
|
=> [#<LEDENET::Device:0x007fff328f4330 @ip="10.133.8.113", @hw_addr="XXXXXXXXXXXX", @model="HF-LPB100-ZJ200">]
|
42
98
|
```
|
43
99
|
|
44
|
-
|
100
|
+
#### API
|
45
101
|
|
46
102
|
To construct an API class, use the following:
|
47
103
|
|
@@ -61,7 +117,7 @@ By default, the API will re-try transient-looking failures three times. You can
|
|
61
117
|
api = LEDENET::Api.new('10.133.8.113', reuse_connection: true, max_retries: 0)
|
62
118
|
```
|
63
119
|
|
64
|
-
|
120
|
+
#### Status
|
65
121
|
|
66
122
|
To check if the controller is currently on:
|
67
123
|
|
@@ -77,7 +133,7 @@ api.on
|
|
77
133
|
api.off
|
78
134
|
```
|
79
135
|
|
80
|
-
|
136
|
+
#### Color / Warm White
|
81
137
|
|
82
138
|
To get the current color settings:
|
83
139
|
|
data/bin/ledenet-ufo
CHANGED
@@ -20,7 +20,7 @@ if ARGV.count > 0 && !ARGV.first.start_with?('-')
|
|
20
20
|
if IPAddress.valid?(arg)
|
21
21
|
options[:ip] = arg
|
22
22
|
elsif /^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i.match(arg)
|
23
|
-
options[:hw_addr] = arg
|
23
|
+
options[:hw_addr] = arg.gsub(':', '').upcase
|
24
24
|
else
|
25
25
|
raise "Invalid device speicifier \"#{arg}\". Must be ip or mac address."
|
26
26
|
end
|
@@ -53,7 +53,7 @@ opts = OptionParser.new do |opts|
|
|
53
53
|
options[:on?] = false
|
54
54
|
end
|
55
55
|
|
56
|
-
opts.on("-l", "--list", Integer, "Prints a list of available devices and
|
56
|
+
opts.on("-l", "--list", Integer, "Prints a list of available devices and exits") do |v|
|
57
57
|
options[:list] = true
|
58
58
|
end
|
59
59
|
|
@@ -87,7 +87,12 @@ begin
|
|
87
87
|
printf row_format, "IP ADDRESS", "HW ADDRESS", "Model #"
|
88
88
|
|
89
89
|
LEDENET.discover_devices.each do |device|
|
90
|
-
|
90
|
+
formatted_hwaddr = (0...12).step(2)
|
91
|
+
.map { |x| device.hw_addr[x, 2] }
|
92
|
+
.join(':')
|
93
|
+
.downcase
|
94
|
+
|
95
|
+
printf row_format, device.ip, formatted_hwaddr, device.model
|
91
96
|
end
|
92
97
|
else
|
93
98
|
ip = nil
|
data/lib/ledenet/version.rb
CHANGED