line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Device::Yeelight::Light; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
18
|
use 5.026; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
16
|
|
5
|
1
|
|
|
1
|
|
22
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
17
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
9
|
1
|
|
|
1
|
|
671
|
use JSON; |
|
1
|
|
|
|
|
12161
|
|
|
1
|
|
|
|
|
5
|
|
10
|
1
|
|
|
1
|
|
111
|
use IO::Socket; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=encoding utf8 |
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Device::Yeelight::Light - WiFi Smart LED Light |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.10 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This module provides base class for Yeelight smart device |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 new |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Creates new Yeelight light device. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
38
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
39
|
0
|
|
|
|
|
|
my $data = { |
40
|
|
|
|
|
|
|
id => undef, |
41
|
|
|
|
|
|
|
location => 'yeelight://', |
42
|
|
|
|
|
|
|
support => [], |
43
|
|
|
|
|
|
|
@_, |
44
|
|
|
|
|
|
|
_socket => undef, |
45
|
|
|
|
|
|
|
_next_command_id => 1, |
46
|
|
|
|
|
|
|
}; |
47
|
0
|
|
|
|
|
|
return bless( $data, $class ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub DESTROY { |
51
|
0
|
|
|
0
|
|
|
my $self = shift; |
52
|
0
|
0
|
|
|
|
|
$self->{_socket}->close if defined $self->{_socket}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 is_supported |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Checks if method is supported by the device. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub is_supported { |
62
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
63
|
0
|
|
|
|
|
|
my ($method) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
unless ( grep { $method =~ m/::$_$/ } @{ $self->{support} } ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
carp "$method is not supported by this device"; |
67
|
0
|
|
|
|
|
|
return; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return 1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub AUTOLOAD { |
74
|
0
|
|
|
0
|
|
|
my $self = shift; |
75
|
0
|
|
|
|
|
|
our $AUTOLOAD; |
76
|
0
|
0
|
|
|
|
|
return unless $self->is_supported($AUTOLOAD); |
77
|
0
|
|
|
|
|
|
$self->call( $AUTOLOAD, @_ ); |
78
|
0
|
|
|
|
|
|
return $self; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub command_id { |
82
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
83
|
0
|
|
|
|
|
|
$self->{_next_command_id}++; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 connection |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Create and return socket connected to the device. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub connection { |
93
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
94
|
|
|
|
|
|
|
return $self->{_socket} |
95
|
0
|
0
|
0
|
|
|
|
if defined $self->{_socket} and $self->{_socket}->connected; |
96
|
0
|
|
|
|
|
|
my ( $addr, $port ) = $self->{location} =~ m#yeelight://([^:]*):(\d*)#; |
97
|
0
|
0
|
|
|
|
|
$self->{_socket} = IO::Socket::INET->new( |
98
|
|
|
|
|
|
|
PeerAddr => $addr, |
99
|
|
|
|
|
|
|
PeerPort => $port, |
100
|
|
|
|
|
|
|
ReuseAddr => 1, |
101
|
|
|
|
|
|
|
Proto => 'tcp', |
102
|
|
|
|
|
|
|
) or croak $!; |
103
|
0
|
|
|
|
|
|
return $self->{_socket}; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 call |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Sends command to device. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub call { |
113
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
114
|
0
|
|
|
|
|
|
my ( $cmd, @params ) = @_; |
115
|
0
|
|
|
|
|
|
my $id = $self->command_id; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
my $package = __PACKAGE__; |
118
|
0
|
|
|
|
|
|
my $json = encode_json( |
119
|
|
|
|
|
|
|
{ |
120
|
|
|
|
|
|
|
id => $id, |
121
|
|
|
|
|
|
|
method => $cmd =~ s/^${package}:://r, |
122
|
|
|
|
|
|
|
params => \@params, |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
); |
125
|
0
|
0
|
|
|
|
|
$self->connection->send("$json\r\n") or croak $!; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my $buffer; |
128
|
0
|
|
|
|
|
|
while ( not $self->connection->recv( $buffer, 4096 ) ) { |
129
|
0
|
|
|
|
|
|
my $response = decode_json($buffer); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# Ignore notification messages |
132
|
0
|
0
|
|
|
|
|
next if not defined $response->{id}; |
133
|
|
|
|
|
|
|
carp "Received response to unkown command $response->{id}" |
134
|
0
|
0
|
|
|
|
|
if $response->{id} != $id; |
135
|
0
|
0
|
|
|
|
|
if ( defined $response->{error} ) { |
136
|
0
|
|
|
|
|
|
carp |
137
|
|
|
|
|
|
|
"$response->{error}->{message} (code $response->{error}->{code})"; |
138
|
0
|
|
|
|
|
|
return; |
139
|
|
|
|
|
|
|
} |
140
|
0
|
|
|
|
|
|
return @{ $response->{result} }; |
|
0
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 Yeelight API CALLS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
use subs |
149
|
1
|
|
|
1
|
|
1609
|
qw/get_prop set_ct_abx set_rgb set_hsv set_bright set_power toggle set_default start_cf stop_cf set_scene cron_add cron_get cron_del set_adjust set_music set_name bg_set_rgb bg_set_hsv bg_set_ct_abx bg_start_cf bg_stop_cf bg_set_scene bg_set_default bg_set_power bg_set_bright bg_set_adjust bg_toggle dev_toggle adjust_bright adjust_ct adjust_color bg_adjust_bright bg_adjust_ct/; |
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
5
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 get_prop |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This method is used to retrieve current property of smart LED. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub get_prop { |
158
|
0
|
|
|
0
|
|
|
my $self = shift; |
159
|
0
|
|
|
|
|
|
my (@properties) = @_; |
160
|
0
|
0
|
|
|
|
|
return unless $self->is_supported( ( caller(0) )[3] ); |
161
|
0
|
|
|
|
|
|
my @res = $self->call( 'get_prop', @_ ); |
162
|
0
|
|
|
|
|
|
my $props; |
163
|
0
|
|
|
|
|
|
for my $i ( 0 .. $#properties ) { |
164
|
0
|
|
|
|
|
|
$props->{ $properties[$i] } = $res[$i]; |
165
|
|
|
|
|
|
|
} |
166
|
0
|
|
|
|
|
|
return $props; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 set_ct_abx |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This method is used to change the color temperature of a smart LED. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head4 Parameters |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item ct_value |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Target color temperature. The type is integer and range is 1700 ~ 6500 (k). |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item effect |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Support two values: I and I. If effect is I, then the |
184
|
|
|
|
|
|
|
color temperature will be changed directly to target value, under this case, |
185
|
|
|
|
|
|
|
the third parameter I is ignored. If effect is I, then the |
186
|
|
|
|
|
|
|
color temperature will be changed to target value in a gradual fashion, under |
187
|
|
|
|
|
|
|
this case, the total time of gradual change is specified in third parameter |
188
|
|
|
|
|
|
|
I. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item duration |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Specifies the total time of the gradual changing. The unit is milliseconds. The |
193
|
|
|
|
|
|
|
minimum support duration is 30 milliseconds. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=back |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 set_rgb |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This method is used to change the color of a smart LED. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head4 Parameters |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=over |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item rgb_value |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Target color, whose type is integer. It should be expressed in decimal integer |
208
|
|
|
|
|
|
|
ranges from 0 to 16777215 (hex: 0xFFFFFF). |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item effect |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Refer to C method. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item duration |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Refer to C method. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=back |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head2 set_hsv |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
This method is used to change the color of a smart LED. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head4 Parameters |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=over |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item hue |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Target hue value, whose type is integer. It should be expressed in decimal |
231
|
|
|
|
|
|
|
integer ranges from 0 to 359. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item sat |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Target saturation value whose type is integer. It's range is 0 to 100. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item effect |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Refer to C method. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=item duration |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Refer to C method. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=back |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head2 set_bright |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
This method is used to change the brightness of a smart LED. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head4 Parameters |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=over |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item brightness |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Target brightness. The type is integer and ranges from 1 to 100. The brightness |
258
|
|
|
|
|
|
|
is a percentage instead of a absolute value. 100 means maximum brightness while |
259
|
|
|
|
|
|
|
1 means the minimum brightness. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=item effect |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Refer to C method. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=item duration |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
Refer to C method. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=back |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head2 set_power |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
This method is used to switch on or off the smart LED (software |
274
|
|
|
|
|
|
|
managed on/off). |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head4 Parameters |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=over |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=item power |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Can only be I or I. I means turn on the smart LED, I means turn |
283
|
|
|
|
|
|
|
off the smart LED. |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=item effect |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
Refer to C method. |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=item duration |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
Refer to C method. |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=item mode |
294
|
|
|
|
|
|
|
(optional parameter) |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=over |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=item 0 |
299
|
|
|
|
|
|
|
Normal turn on operation (default value) |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=item 1 |
302
|
|
|
|
|
|
|
Turn on and switch to CT mode. |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=item 2 |
305
|
|
|
|
|
|
|
Turn on and switch to RGB mode. |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=item 3 |
308
|
|
|
|
|
|
|
Turn on and switch to HSV mode. |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=item 4 |
311
|
|
|
|
|
|
|
Turn on and switch to color flow mode. |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=item 5 |
314
|
|
|
|
|
|
|
Turn on and switch to Night light mode. (Ceiling light only). |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=back |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=back |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
=head2 toggle |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
This method is used to toggle the smart LED. |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
=head2 set_default |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
This method is used to save current state of smart LED in persistent memory. So |
327
|
|
|
|
|
|
|
if user powers off and then powers on the smart LED again (hard power reset), |
328
|
|
|
|
|
|
|
the smart LED will show last saved state. |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
=head2 start_cf |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
This method is used to start a color flow. Color flow is a series of smart LED |
333
|
|
|
|
|
|
|
visible state changing. It can be brightness changing, color changing or color |
334
|
|
|
|
|
|
|
temperature changing. This is the most powerful command. |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
=head4 Parameters |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=over |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
=item count |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
Total number of visible state changing before color flow stopped. 0 means |
343
|
|
|
|
|
|
|
infinite loop on the state changing. |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
=item action |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
The action taken after the flow is stopped. |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=over |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=item 0 |
352
|
|
|
|
|
|
|
means smart LED recover to the state before the color flow started. |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=item 1 |
355
|
|
|
|
|
|
|
means smart LED stay at the state when the flow is stopped. |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
=item 2 |
358
|
|
|
|
|
|
|
means turn off the smart LED after the flow is stopped. |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=back |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
=item flow_expression |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
The expression of the state changing series. |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=over |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
=item Duration |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
Gradual change time or sleep time, in milliseconds, minimum value 50. |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
=item Mode |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
=over |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
=item 1 |
377
|
|
|
|
|
|
|
color |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
=item 2 |
380
|
|
|
|
|
|
|
color temperature |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=item 7 |
383
|
|
|
|
|
|
|
sleep |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
=back |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
=item Value |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
=over |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
=item |
392
|
|
|
|
|
|
|
RGB value when mode is 1, |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=item |
395
|
|
|
|
|
|
|
CT value when mode is 2, |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
=item |
398
|
|
|
|
|
|
|
Ignored when mode is 7 |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
=back |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=item Brightness |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
Brightness value, -1 or 1 ~ 100. Ignored when mode is 7. When this value is |
405
|
|
|
|
|
|
|
-1, brightness in this tuple is ignored (only color or CT change takes effec |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
=back |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
=back |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=head2 stop_cf |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
This method is used to stop a running color flow. |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=head2 set_scene |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
This method is used to set the smart LED directly to specified state. If the |
418
|
|
|
|
|
|
|
smart LED is off, then it will turn on the smart LED firstly and then apply the |
419
|
|
|
|
|
|
|
specified command. |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=head4 Parameters |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
=over |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
=item class |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
=over |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
=item I |
430
|
|
|
|
|
|
|
means change the smart LED to specified color and brightness |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
=item I |
433
|
|
|
|
|
|
|
means change the smart LED to specified color and brightness |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=item I |
436
|
|
|
|
|
|
|
means change the smart LED to specified ct and brightness |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
=item I |
439
|
|
|
|
|
|
|
means start a color flow in specified fashion |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=item I |
442
|
|
|
|
|
|
|
means turn on the smart LED to specified brightness and start a sleep timer to |
443
|
|
|
|
|
|
|
turn off the light after the specified minutes |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
=back |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
=item val1 |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
=item val2 |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
=item val3 |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
=back |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
=head2 cron_add |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
This method is used to start a timer job on the smart LED. |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
=head4 Parameters |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
=over |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=item type |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
Currently can only be 0 (means power off). |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
=item value |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
Length of the timer (in minutes). |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=back |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
=head2 cron_get |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
This method is used to retrieve the setting of the current cron job of the |
476
|
|
|
|
|
|
|
specified type. |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
=head4 Parameters |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
=over |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
=item type |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
The type of the cron job (currently only support 0). |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=back |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
=head2 cron_del |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
This method is used to stop the specified cron job. |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
=head4 Parameters |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
=over |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
=item type |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
The type of the cron job (currently only support 0). |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=back |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
=head2 set_adjust |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
This method is used to change brightness, CT or color of a smart LED without |
505
|
|
|
|
|
|
|
knowing the current value, it's main used by controllers. |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=head4 Parameters |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
=over |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
=item action |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
The direction of the adjustment, the valid value can be: |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
=over |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
=item I |
518
|
|
|
|
|
|
|
increase the specified property |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
=item I |
521
|
|
|
|
|
|
|
decrease the specified property |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
=item I |
524
|
|
|
|
|
|
|
increase the specified property, after it reaches the max value, go back to |
525
|
|
|
|
|
|
|
minimum value |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
=back |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
=item prop |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
The property to adjust. The valid value can be: |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
=over |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
=item I |
536
|
|
|
|
|
|
|
adjust brightness |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
=item I |
539
|
|
|
|
|
|
|
adjust color temperature |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
=item I |
542
|
|
|
|
|
|
|
adjust color. |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
(When C is I, the C can only be I, otherwise, it |
545
|
|
|
|
|
|
|
will be deemed as invalid request.) |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=back |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=back |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
=head2 set_music |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
This method is used to start or stop music mode on a device. Under music mode, |
554
|
|
|
|
|
|
|
no property will be reported and no message quota is checked. |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
=head4 Parameters |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
=over |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
=item action |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
The action of C command. The valid value can be: |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
=over |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=item 0 |
567
|
|
|
|
|
|
|
turn off music mode |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
=item 1 |
570
|
|
|
|
|
|
|
turn on music mode |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
=back |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
=item host |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
The IP address of the music server. |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
=item port |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
The TCP port music application is listening on. |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
=back |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
=head2 set_name |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
This method is used to name the device. The name will be stored on the device |
587
|
|
|
|
|
|
|
and reported in discovering response. User can also read the name through |
588
|
|
|
|
|
|
|
C method. |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
=head4 Parameters |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
=over |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
=item name |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
The name of the device. |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
=back |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
=head2 adjust_bright |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
This method is used to adjust the brightness by specified percentage within |
603
|
|
|
|
|
|
|
specified duration. |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
=head4 Parameters |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
=over |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=item percentage |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
The percentage to be adjusted. The range is: -100 ~ 100 |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
=item duration |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
Refer to "set_ct_abx" method. |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
=back |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=head2 adjust_ct |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
This method is used to adjust the color temperature by specified percentage |
622
|
|
|
|
|
|
|
within specified duration. |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
=head4 Parameters |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
=over |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
=item percentage |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
The percentage to be adjusted. The range is: -100 ~ 100 |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=item duration |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
Refer to "set_ct_abx" method. |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
=back |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
=head2 adjust_color |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
This method is used to adjust the color within specified duration. |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
=head4 Parameters |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
=over |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
=item percentage |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
The percentage to be adjusted. The range is: -100 ~ 100 |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
=item duration |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
Refer to "set_ct_abx" method. |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
=back |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
=head2 bg_set_xxx / bg_toggle |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
These methods are used to control background light, for each command detail, |
659
|
|
|
|
|
|
|
refer to set_xxx command. |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
Refer to C command. |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
=head2 bg_adjust_xxx |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
This method is used to adjust background light by specified percentage within |
666
|
|
|
|
|
|
|
specified duration. |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
Refer to C, C, C. |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
=head2 dev_toggle |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
This method is used to toggle the main light and background light at the same |
673
|
|
|
|
|
|
|
time. |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
=head1 AUTHOR |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
Jan Baier, C<< >> |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
=head1 SEE ALSO |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
This API is described in the Yeeling WiFi Light Inter-Operation Specification. |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
Copyright 2019 Jan Baier. |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
688
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
689
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
See L for more information. |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
=cut |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
1; # End of Device::Yeelight |