xilight 0.1.2 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/README.md +224 -5
- data/exe/yee +80 -21
- data/lib/xilight.rb +50 -22
- data/lib/xilight/version.rb +1 -1
- data/xilight.gemspec +2 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea851e96b3485f0636a8ab5454f3a4f69974a6458bc1daa895359683db617313
|
4
|
+
data.tar.gz: 3c9a553e3f3a5b6d84c1dc3234f1a643ac8bca009edd0546051451ece21e23f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53f825c16afb69fdf0e762e899d9f4f59292795d2bb18e45b522715954a684675f73eb0ef4431b1fb0e0905fda6178d87122a8439a693c6d63d825d081ada49d
|
7
|
+
data.tar.gz: f04becf98cf2b9cd3842b460816967078ffa81dddeb2d0b8df8c5deee6fb5426328d3acef1ff3868a3fad8949e651d0e6b6d8773e25ba08dcf4d7f339d4c3524
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.0
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# Xilight
|
2
2
|
|
3
|
-
|
3
|
+
Xilight provides a Ruby library and a CLI interface to control your Xiaomi Yeelight programmatically.
|
4
4
|
|
5
|
-
|
5
|
+
**Note**: It requires your yeelight to be configured to [development mode](https://www.yeelight.com/en_US/developer).
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,7 +22,226 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
### Library
|
26
|
+
|
27
|
+
Read the API docs [here](https://rubydoc.info/github/wouterken/xilight/master/Xilight/Yeelight).
|
28
|
+
|
29
|
+
### CLI
|
30
|
+
|
31
|
+
#### Help
|
32
|
+
|
33
|
+
yee -h
|
34
|
+
|
35
|
+
#### Discovery
|
36
|
+
Command:
|
37
|
+
yee discover
|
38
|
+
|
39
|
+
Usage:
|
40
|
+
yee discover
|
41
|
+
|
42
|
+
Description:
|
43
|
+
Discover Yeelights and save to ~/.config/.yeelights
|
44
|
+
|
45
|
+
Options:
|
46
|
+
--help, -h # Print this help
|
47
|
+
|
48
|
+
Examples:
|
49
|
+
yee discover
|
50
|
+
|
51
|
+
#### List Lights
|
52
|
+
|
53
|
+
Command:
|
54
|
+
yee list
|
55
|
+
|
56
|
+
Usage:
|
57
|
+
yee list
|
58
|
+
|
59
|
+
Description:
|
60
|
+
List known Yeelights
|
61
|
+
|
62
|
+
Options:
|
63
|
+
--help, -h # Print this help
|
64
|
+
|
65
|
+
Examples:
|
66
|
+
yee list
|
67
|
+
|
68
|
+
#### Set Light Name
|
69
|
+
|
70
|
+
Command:
|
71
|
+
yee name
|
72
|
+
|
73
|
+
Usage:
|
74
|
+
yee name NAME
|
75
|
+
|
76
|
+
Description:
|
77
|
+
Set name for Yeelight
|
78
|
+
|
79
|
+
Arguments:
|
80
|
+
NAME # REQUIRED Name to set for light
|
81
|
+
|
82
|
+
Options:
|
83
|
+
--light=VALUE, -l VALUE # ID/index of Yeelight to target, default: "0"
|
84
|
+
--help, -h # Print this help
|
85
|
+
|
86
|
+
Examples:
|
87
|
+
yee name name -l 1 foo # Set the name for light#1 to "foo"
|
88
|
+
|
89
|
+
|
90
|
+
#### Set RGB
|
91
|
+
|
92
|
+
Command:
|
93
|
+
yee rgb
|
94
|
+
|
95
|
+
Usage:
|
96
|
+
yee rgb R G B
|
97
|
+
|
98
|
+
Description:
|
99
|
+
Set RGB for Yeelight
|
100
|
+
|
101
|
+
Arguments:
|
102
|
+
R # REQUIRED Red (0-255)
|
103
|
+
G # REQUIRED Green (0-255)
|
104
|
+
B # REQUIRED Blue (0-255)
|
105
|
+
|
106
|
+
Options:
|
107
|
+
--light=VALUE, -l VALUE # ID/index of Yeelight to target, default: "0"
|
108
|
+
--name=VALUE, -n VALUE # Name of Yeelight to target
|
109
|
+
--help, -h # Print this help
|
110
|
+
|
111
|
+
Examples:
|
112
|
+
yee rgb 255 0 0 # set light to red (red 255, green 0, blue 0)
|
113
|
+
yee rgb 0 0 180 -n foo# set light with name foo to blue (red 0, green 0, blue 180)
|
114
|
+
yee rgb 255 255 255 -l 3# set light #3 to white (red 255, green 255, blue 255)
|
115
|
+
|
116
|
+
|
117
|
+
#### Brightness
|
118
|
+
|
119
|
+
Command:
|
120
|
+
yee bright
|
121
|
+
|
122
|
+
Usage:
|
123
|
+
yee bright BRIGHTNESS
|
124
|
+
|
125
|
+
Description:
|
126
|
+
Set Brightness for Yeelight
|
127
|
+
|
128
|
+
Arguments:
|
129
|
+
BRIGHTNESS # REQUIRED Brightness (0-100)
|
130
|
+
|
131
|
+
Options:
|
132
|
+
--light=VALUE, -l VALUE # ID/index of Yeelight to target, default: "0"
|
133
|
+
--name=VALUE, -n VALUE # Name of Yeelight to target
|
134
|
+
--help, -h # Print this help
|
135
|
+
|
136
|
+
Examples:
|
137
|
+
yee bright 100 # full brightness
|
138
|
+
yee bright 50 -n foo # 50% brightness for light with name foo
|
139
|
+
yee bright 25 -l 3 # 25% brightness for light#3
|
140
|
+
|
141
|
+
#### Set HSV
|
142
|
+
|
143
|
+
Command:
|
144
|
+
yee hsv
|
145
|
+
|
146
|
+
Usage:
|
147
|
+
yee hsv H S
|
148
|
+
|
149
|
+
Description:
|
150
|
+
Set HSV for Yeelight
|
151
|
+
|
152
|
+
Arguments:
|
153
|
+
H # REQUIRED Hue (0-359)
|
154
|
+
S # REQUIRED Saturation (0-100)
|
155
|
+
|
156
|
+
Options:
|
157
|
+
--light=VALUE, -l VALUE # ID/index of Yeelight to target, default: "0"
|
158
|
+
--name=VALUE, -n VALUE # Name of Yeelight to target
|
159
|
+
--help, -h # Print this help
|
160
|
+
|
161
|
+
Examples:
|
162
|
+
yee hsv 180 40 # set hue to 180 and saturation to 40
|
163
|
+
yee hsv 200 20 -n foo# set light with name foo to hue: 200, saturation: 20
|
164
|
+
yee hsv 359 90 -l 3# set light #3 to hue: 359, saturation: 90
|
165
|
+
|
166
|
+
#### Turn Off
|
167
|
+
|
168
|
+
Command:
|
169
|
+
yee off
|
170
|
+
|
171
|
+
Usage:
|
172
|
+
yee off
|
173
|
+
|
174
|
+
|
175
|
+
Description:
|
176
|
+
Turn Off Yeelight
|
177
|
+
|
178
|
+
Options:
|
179
|
+
--light=VALUE, -l VALUE # ID/index of Yeelight to target, default: "0"
|
180
|
+
--name=VALUE, -n VALUE # Name of Yeelight to target
|
181
|
+
--help, -h # Print this help
|
182
|
+
|
183
|
+
Examples:
|
184
|
+
yee off # turn default/first light off
|
185
|
+
yee off -n kitchen # turn light with name 'kitchen' off
|
186
|
+
yee off -l 3 # turn light #3 off
|
187
|
+
|
188
|
+
#### Turn On
|
189
|
+
Command:
|
190
|
+
yee on
|
191
|
+
|
192
|
+
Usage:
|
193
|
+
yee on
|
194
|
+
|
195
|
+
Description:
|
196
|
+
Turn on Yeelight
|
197
|
+
|
198
|
+
Options:
|
199
|
+
--light=VALUE, -l VALUE # ID/index of Yeelight to target, default: "0"
|
200
|
+
--name=VALUE, -n VALUE # Name of Yeelight to target
|
201
|
+
--help, -h # Print this help
|
202
|
+
|
203
|
+
Examples:
|
204
|
+
yee on # turn default/first light on
|
205
|
+
yee on -n kitchen # turn light with name 'kitchen' on
|
206
|
+
yee on -l 3 # turn light #3 on
|
207
|
+
|
208
|
+
#### Toggle
|
209
|
+
|
210
|
+
Command:
|
211
|
+
yee toggle
|
212
|
+
|
213
|
+
Usage:
|
214
|
+
yee toggle
|
215
|
+
|
216
|
+
Description:
|
217
|
+
Toggle Yeelight
|
218
|
+
|
219
|
+
Options:
|
220
|
+
--light=VALUE, -l VALUE # ID/index of Yeelight to target, default: "0"
|
221
|
+
--name=VALUE, -n VALUE # Name of Yeelight to target
|
222
|
+
--help, -h # Print this help
|
223
|
+
|
224
|
+
Examples:
|
225
|
+
yee toggle # toggle default/first light
|
226
|
+
yee toggle -n kitchen # toggle light with name 'kitchen'
|
227
|
+
yee toggle -l 3 # toggle light #3
|
228
|
+
|
229
|
+
#### Version
|
230
|
+
|
231
|
+
Command:
|
232
|
+
yee version
|
233
|
+
|
234
|
+
Usage:
|
235
|
+
yee version
|
236
|
+
|
237
|
+
Description:
|
238
|
+
Print version
|
239
|
+
|
240
|
+
Options:
|
241
|
+
--help, -h # Print this help
|
242
|
+
|
243
|
+
Examples:
|
244
|
+
yee version
|
26
245
|
|
27
246
|
## Development
|
28
247
|
|
@@ -32,5 +251,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
251
|
|
33
252
|
## Contributing
|
34
253
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
254
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/wouterken/xilight. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
255
|
|
data/exe/yee
CHANGED
@@ -20,14 +20,28 @@ module Xilight
|
|
20
20
|
{}
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.
|
23
|
+
def self.rgb_to_hex(r,g,b)
|
24
|
+
[r,g,b].map{|x| x.to_i.to_s(16).rjust(2, '0') }.join
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.rgb_to_i(r,g,b)
|
28
|
+
rgb_to_hex(r,g,b).to_i(16)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.get_light(index, name=nil, attempt: 0)
|
24
32
|
lights = ::Xilight::CLI.config['yeelights']
|
25
33
|
light_attribs = if name && name != ''
|
26
34
|
lights.find{|l| l['name'].downcase.strip == name.downcase.strip }
|
27
35
|
else
|
28
36
|
lights[index.to_i]
|
29
37
|
end
|
30
|
-
::Xilight::Yeelight.new(light_attribs.map{|k,v| [k.to_sym, v]}.to_h)
|
38
|
+
light = ::Xilight::Yeelight.new(**light_attribs.map{|k,v| [k.to_sym, v]}.to_h)
|
39
|
+
unless light.available?
|
40
|
+
self.discover
|
41
|
+
get_light(index, name, attempt: 1) if attempt.zero?
|
42
|
+
else
|
43
|
+
light
|
44
|
+
end
|
31
45
|
rescue
|
32
46
|
puts "Couldn't find light with " + ((name && name != '') ? "name #{name}" : "ID #{index}")
|
33
47
|
puts "Known lights:"
|
@@ -35,6 +49,23 @@ module Xilight
|
|
35
49
|
exit(1)
|
36
50
|
end
|
37
51
|
|
52
|
+
def self.discover
|
53
|
+
::Xilight::CLI.config = {
|
54
|
+
'yeelights' => ::Xilight::Yeelight.discover.map do |light|
|
55
|
+
light.instance_variables.map{|v| [v.to_s[1..-1], light.instance_variable_get(v)] }.to_h
|
56
|
+
end
|
57
|
+
}
|
58
|
+
self.list
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.list
|
62
|
+
current_config = ::Xilight::CLI.config
|
63
|
+
current_lights = current_config.fetch('yeelights', [])
|
64
|
+
current_lights.each_with_index do |light, index|
|
65
|
+
puts "Light ##{index} => #{(light['name'] || light['id'])}@#{light['host']}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
38
69
|
module Commands
|
39
70
|
extend Dry::CLI::Registry
|
40
71
|
|
@@ -58,17 +89,7 @@ module Xilight
|
|
58
89
|
]
|
59
90
|
|
60
91
|
def call(**)
|
61
|
-
|
62
|
-
current_lights = current_config.fetch('yeelights', [])
|
63
|
-
::Xilight::Yeelight.discover.each do |light|
|
64
|
-
current_lights.reject!{|l| l['id'] == light.id}
|
65
|
-
current_lights << light.instance_variables.map{|v| [v.to_s[1..-1], light.instance_variable_get(v)] }.to_h
|
66
|
-
end
|
67
|
-
current_config['yeelights'] = current_lights
|
68
|
-
current_lights.each_with_index do |light, index|
|
69
|
-
puts "Light ##{index} => #{(light['name'] || light['id'])}@#{light['host']}"
|
70
|
-
end
|
71
|
-
::Xilight::CLI.config = current_config
|
92
|
+
::Xilight::CLI.discover
|
72
93
|
end
|
73
94
|
end
|
74
95
|
|
@@ -80,11 +101,7 @@ module Xilight
|
|
80
101
|
]
|
81
102
|
|
82
103
|
def call(**)
|
83
|
-
|
84
|
-
current_lights = current_config.fetch('yeelights', [])
|
85
|
-
current_lights.each_with_index do |light, index|
|
86
|
-
puts "Light ##{index} => #{(light['name'] || light['id'])}@#{light['host']}"
|
87
|
-
end
|
104
|
+
::Xilight::CLI.list
|
88
105
|
end
|
89
106
|
end
|
90
107
|
|
@@ -104,8 +121,7 @@ module Xilight
|
|
104
121
|
|
105
122
|
def call(r:, g:, b:, light: 0, name: nil, **)
|
106
123
|
light =::Xilight::CLI.get_light(light, name)
|
107
|
-
|
108
|
-
light.rgb = as_hex.to_i(16)
|
124
|
+
light.rgb = ::Xilight::CLI.rgb_to_i(r,g,b)
|
109
125
|
end
|
110
126
|
end
|
111
127
|
|
@@ -214,6 +230,44 @@ module Xilight
|
|
214
230
|
end
|
215
231
|
end
|
216
232
|
|
233
|
+
module ColorFlow
|
234
|
+
class On < Dry::CLI::Command
|
235
|
+
desc "Start ColorFlow"
|
236
|
+
option :light, desc: "ID/index of Yeelight to target", default: "0", aliases: ["-l"]
|
237
|
+
option :name, desc: "Name of Yeelight to target", default: nil, aliases: ["-n"]
|
238
|
+
|
239
|
+
example [
|
240
|
+
"on # start color flow on default/first light",
|
241
|
+
"on -n kitchen # start color flow on light with name 'kitchen'",
|
242
|
+
"on -l 3 # start color flow on light #3"
|
243
|
+
]
|
244
|
+
def call(light: 0, name: nil, **)
|
245
|
+
light =::Xilight::CLI.get_light(light, name)
|
246
|
+
flow_expression = COLORS.values.first(12).each_slice(2).map(&:first).map do |(r,g,b)|
|
247
|
+
"4000,1,#{::Xilight::CLI.rgb_to_i(r,g,b)},100"
|
248
|
+
end.join(',')
|
249
|
+
light.start_cf(0, 1, flow_expression)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
class Off < Dry::CLI::Command
|
254
|
+
desc "Stop ColorFlow"
|
255
|
+
option :light, desc: "ID/index of Yeelight to target", default: "0", aliases: ["-l"]
|
256
|
+
option :name, desc: "Name of Yeelight to target", default: nil, aliases: ["-n"]
|
257
|
+
|
258
|
+
example [
|
259
|
+
"off # start color flow on default/first light",
|
260
|
+
"off -n kitchen # start color flow on light with name 'kitchen'",
|
261
|
+
"off -l 3 # start color flow on light #3"
|
262
|
+
]
|
263
|
+
|
264
|
+
def call(light: 0, name: nil, **)
|
265
|
+
light =::Xilight::CLI.get_light(light, name)
|
266
|
+
light.power = 'off'
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
217
271
|
COLORS = {
|
218
272
|
red: [255, 0, 0],
|
219
273
|
orange: [255, 128, 0],
|
@@ -236,7 +290,7 @@ module Xilight
|
|
236
290
|
Object.const_set(class_name, Class.new(Dry::CLI::Command) do
|
237
291
|
desc "Set yeelight to color #{color}"
|
238
292
|
example [
|
239
|
-
"
|
293
|
+
""
|
240
294
|
]
|
241
295
|
|
242
296
|
option :light, desc: "ID/index of Yeelight to target", default: "0", aliases: ["-l"]
|
@@ -257,6 +311,11 @@ module Xilight
|
|
257
311
|
end
|
258
312
|
end
|
259
313
|
|
314
|
+
register "color_flow", aliases: ["cf"] do |prefix|
|
315
|
+
prefix.register "on", ColorFlow::On, aliases: ["o"]
|
316
|
+
prefix.register "off", ColorFlow::Off, aliases: ["x"]
|
317
|
+
end
|
318
|
+
|
260
319
|
register "version", Version, aliases: ["v", "-v", "--version"]
|
261
320
|
register "discover", Discover, aliases: ["d"]
|
262
321
|
register "rgb", Rgb
|
data/lib/xilight.rb
CHANGED
@@ -24,12 +24,34 @@ module Xilight
|
|
24
24
|
@port = location[/(?!<:)\d+$/]
|
25
25
|
end
|
26
26
|
|
27
|
+
def available?()
|
28
|
+
begin
|
29
|
+
Timeout::timeout(1) do
|
30
|
+
begin
|
31
|
+
s = TCPSocket.new(@host, @port)
|
32
|
+
s.close
|
33
|
+
return true
|
34
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
35
|
+
return false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
rescue Timeout::Error
|
39
|
+
end
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
|
27
43
|
def request(cmd)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
44
|
+
begin
|
45
|
+
Timeout.timeout(0.5) do
|
46
|
+
s = TCPSocket.open(@host, @port)
|
47
|
+
s.puts "#{JSON.generate(cmd)}\r\n"
|
48
|
+
data = s.gets.chomp
|
49
|
+
s.close
|
50
|
+
JSON.parse(data)
|
51
|
+
end
|
52
|
+
rescue Timeout::Error
|
53
|
+
puts "Yeelight connection timed out. Yeelight not accessible"
|
54
|
+
end
|
33
55
|
end
|
34
56
|
|
35
57
|
# This method is used to retrieve current property of smart LED.
|
@@ -37,38 +59,44 @@ module Xilight
|
|
37
59
|
request({id: 1,method: 'get_prop', params: values})
|
38
60
|
end
|
39
61
|
|
40
|
-
# This method is used to change the color temperature of
|
62
|
+
# This method is used to change the color temperature of the smart LED.
|
41
63
|
def set_ct_abx(ct_value, effect='smooth', duration=200)
|
42
64
|
request({id: 2,method: 'set_ct_abx', params: [ct_value,effect,duration]})
|
43
65
|
end
|
44
66
|
|
67
|
+
# This method is used to change the color temperature of the smart LED.
|
45
68
|
def ct_abx=ct_value
|
46
69
|
set_ct_abx(ct_value)
|
47
70
|
end
|
48
71
|
|
49
|
-
# This method is used to change the color RGB of
|
72
|
+
# This method is used to change the color RGB of the smart LED.
|
73
|
+
# Expects an integer representing a hex triplet (e.g. 0xFFFFFF )
|
50
74
|
def set_rgb(rgb_value, effect='smooth', duration=200)
|
51
75
|
request({id: 3,method: 'set_rgb', params: [rgb_value,effect,duration]})
|
52
76
|
end
|
53
77
|
|
78
|
+
# This method is used to change the color RGB of the smart LED.
|
79
|
+
# Expects an integer representing a hex triplet (e.g. 0xFFFFFF )
|
54
80
|
def rgb=rgb_value
|
55
81
|
set_rgb(rgb_value)
|
56
82
|
end
|
57
83
|
|
58
|
-
# This method is used to change the color HSV of
|
84
|
+
# This method is used to change the color HSV of the smart LED.
|
59
85
|
def set_hsv(hue, sat, effect='smooth', duration=200)
|
60
86
|
request({id: 4,method: 'set_hsv', params: [hue,sat,effect,duration]})
|
61
87
|
end
|
62
88
|
|
89
|
+
# This method is used to change the color HSV of the smart LED.
|
63
90
|
def hsv=hue
|
64
91
|
set_hsv(hue)
|
65
92
|
end
|
66
93
|
|
67
|
-
# This method is used to change the brightness of
|
94
|
+
# This method is used to change the brightness of the smart LED.
|
68
95
|
def set_bright(brightness, effect='smooth', duration=200)
|
69
96
|
request({id: 5,method: 'set_bright', params: [brightness,effect,duration]})
|
70
97
|
end
|
71
98
|
|
99
|
+
# This method is used to change the brightness of the smart LED.
|
72
100
|
def bright=brightness
|
73
101
|
set_bright(brightness)
|
74
102
|
end
|
@@ -78,6 +106,7 @@ module Xilight
|
|
78
106
|
request({id: 6,method: 'set_power', params: [power,effect,duration]})
|
79
107
|
end
|
80
108
|
|
109
|
+
# This method is used to switch on or off the smart LED (software managed on/off).
|
81
110
|
def power=power
|
82
111
|
set_power(power)
|
83
112
|
end
|
@@ -87,19 +116,18 @@ module Xilight
|
|
87
116
|
request({id: 7,method: 'toggle', params: []})
|
88
117
|
end
|
89
118
|
|
90
|
-
# This method is used to save current state of smart LED in persistent memory.
|
91
|
-
#
|
92
|
-
# the smart LED will show last saved state.
|
93
|
-
# Note: The "automatic state saving" must be turn off
|
119
|
+
# This method is used to save the current state of smart LED in persistent memory.
|
120
|
+
# If user powers off and then powers on the smart LED again (hard power reset),
|
121
|
+
# the smart LED will show last the saved state.
|
94
122
|
def set_default
|
95
123
|
request({id: 8,method: 'set_default', params: []})
|
96
124
|
end
|
97
125
|
|
98
126
|
# This method is used to start a color flow. Color flow is a series of smart
|
99
|
-
# LED visible state
|
127
|
+
# LED visible state changes. It can be either brightness changing, color changing
|
100
128
|
# or color temperature changing
|
101
|
-
def start_cf(count, action, flow_expression)
|
102
|
-
request({id: 9,method: '
|
129
|
+
def start_cf(count=0, action=1, flow_expression="1000,2,2700,100,500,1,255,10,5000,7,0,0,500,2,5000,1")
|
130
|
+
request({id: 9, method: 'start_cf', params: [count,action,flow_expression]})
|
103
131
|
end
|
104
132
|
|
105
133
|
# This method is used to stop a running color flow.
|
@@ -108,8 +136,8 @@ module Xilight
|
|
108
136
|
end
|
109
137
|
|
110
138
|
# This method is used to set the smart LED directly to specified state. If
|
111
|
-
# the smart LED is off, then it will turn on the
|
112
|
-
# apply the specified
|
139
|
+
# the smart LED is off, then it will first turn on the smartLED and then
|
140
|
+
# apply the specified command.
|
113
141
|
def set_scene(classe, val1, val2)
|
114
142
|
request({id: 11,method: 'set_scene', params: [classe,val1,val2]})
|
115
143
|
end
|
@@ -131,14 +159,14 @@ module Xilight
|
|
131
159
|
end
|
132
160
|
|
133
161
|
# This method is used to change brightness, CT or color of a smart LED
|
134
|
-
# without knowing the current value, it's
|
162
|
+
# without knowing the current value, it's mainly used by controllers.
|
135
163
|
def set_adjust(action, prop)
|
136
164
|
request({id: 15,method: 'set_adjust', params: [action,prop]})
|
137
165
|
end
|
138
166
|
|
139
167
|
# This method is used to name the device. The name will be stored on the
|
140
|
-
# device and reported in
|
141
|
-
# through “get_prop” method.
|
168
|
+
# device and reported in the discovery response. Users can also read the device name
|
169
|
+
# through the “get_prop” method.
|
142
170
|
def set_name(name)
|
143
171
|
request({id: 16,method: 'set_name', params: [name]})
|
144
172
|
end
|
@@ -158,7 +186,7 @@ module Xilight
|
|
158
186
|
end
|
159
187
|
|
160
188
|
|
161
|
-
# This method is used to discover a smart LED
|
189
|
+
# This method is used to discover a smart LED on the local network
|
162
190
|
def self.discover
|
163
191
|
host = "239.255.255.250"
|
164
192
|
port = 1982
|
data/lib/xilight/version.rb
CHANGED
data/xilight.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = "Ruby Xiaomi Yeelight gem"
|
13
13
|
spec.description = "Ruby Xiaomi Yeelight gem"
|
14
|
+
spec.homepage = "https://github.com/wouterken/xilight"
|
14
15
|
|
15
16
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
17
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
@@ -29,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
29
30
|
spec.require_paths = ["lib"]
|
30
31
|
spec.add_runtime_dependency "dry-cli"
|
31
32
|
spec.add_development_dependency "bundler", "~> 1.13"
|
32
|
-
spec.add_development_dependency "rake", "
|
33
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
33
34
|
spec.add_development_dependency "pry"
|
34
35
|
spec.add_development_dependency "pry-byebug"
|
35
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xilight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wouter Coppieters
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 12.3.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 12.3.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,6 +89,7 @@ extensions: []
|
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
91
|
- ".gitignore"
|
92
|
+
- ".ruby-version"
|
92
93
|
- CODE_OF_CONDUCT.md
|
93
94
|
- Gemfile
|
94
95
|
- README.md
|
@@ -99,7 +100,7 @@ files:
|
|
99
100
|
- lib/xilight.rb
|
100
101
|
- lib/xilight/version.rb
|
101
102
|
- xilight.gemspec
|
102
|
-
homepage:
|
103
|
+
homepage: https://github.com/wouterken/xilight
|
103
104
|
licenses: []
|
104
105
|
metadata: {}
|
105
106
|
post_install_message:
|
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
- !ruby/object:Gem::Version
|
118
119
|
version: '0'
|
119
120
|
requirements: []
|
120
|
-
rubygems_version: 3.1.
|
121
|
+
rubygems_version: 3.1.2
|
121
122
|
signing_key:
|
122
123
|
specification_version: 4
|
123
124
|
summary: Ruby Xiaomi Yeelight gem
|