-
Notifications
You must be signed in to change notification settings - Fork 0
/
lightserver.html
1225 lines (1198 loc) · 87.2 KB
/
lightserver.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>lightserver — Server exposing an HTTP API for controlling several Philips Hue bridges — Playhouse 0.1 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Playhouse 0.1 documentation" href="index.html" />
<link rel="up" title="Light server" href="backend.html" />
<link rel="next" title="resetutil — Utility for resetting Philips Hue bulbs and pairing them with bridges" href="resetutil.html" />
<link rel="prev" title="playhouse — Python library for communicating with Philips Hue bridges" href="playhouse.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="http-routingtable.html" title="HTTP Routing Table"
>routing table</a> |</li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="resetutil.html" title="resetutil — Utility for resetting Philips Hue bulbs and pairing them with bridges"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="playhouse.html" title="playhouse — Python library for communicating with Philips Hue bridges"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Playhouse 0.1 documentation</a> »</li>
<li><a href="backend.html" accesskey="U">Light server</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-lightserver">
<span id="lightserver-server-exposing-an-http-api-for-controlling-several-philips-hue-bridges"></span><h1><a class="reference internal" href="#module-lightserver" title="lightserver"><tt class="xref py py-mod docutils literal"><span class="pre">lightserver</span></tt></a> — Server exposing an HTTP API for controlling several Philips Hue bridges<a class="headerlink" href="#module-lightserver" title="Permalink to this headline">¶</a></h1>
<p>This is the light server component of the Playhouse project.</p>
<p>The light server handles the current light grid configuration (with Hue bridges and lights)
and the communication between the application (typically the Playhouse web server)
and the separate Hue bridges. It exposes an HTTP API to enable remote control of the
lights over the network; see <a class="reference internal" href="#api"><em>The API</em></a>.</p>
<div class="section" id="running-the-server">
<h2>Running the server<a class="headerlink" href="#running-the-server" title="Permalink to this headline">¶</a></h2>
<div class="section" id="dependencies">
<h3>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Python 3.3+</li>
<li>Tornado 3.2+</li>
<li>PycURL 7.19.3+</li>
<li>libcurl 7.21.1+</li>
<li>jsonschema 2.3.0+</li>
</ul>
</div>
<div class="section" id="setup">
<h3>Setup<a class="headerlink" href="#setup" title="Permalink to this headline">¶</a></h3>
<p>The Hue bridges themselves have no HTTPS support, and the protection against unauthorized commands
is very weak. Therefore, it is strongly recommended to set up the Hue bridges in an
internal network configured so that they cannot communicate with the outside world directly.
The Hue bridges communicate through port 80 and 30000, so this can be done by configuring
a firewall to restrict access through those ports.
The light server must then be run within this internal network.</p>
<p>The light server supports HTTPS for communication between itself and the application,
and can therefore safely communicate with the outside world if HTTPS is configured and enabled.
Additionally, authentication can be enabled so that a valid password will be required
in order to send requests to the light server.</p>
<p>The standard port for the light server is 4711.</p>
<p>The light server setup is a few simple steps:</p>
<ol class="arabic simple">
<li>Download all files from the playhouse-lights repository to the computer where
the light server will run. This can be done by running
<tt class="docutils literal"><span class="pre">git</span> <span class="pre">clone</span> <span class="pre">https://github.com/smab/playhouse-lights.git</span></tt>.</li>
<li>If you do not already have a config file, copy the file <tt class="docutils literal"><span class="pre">config.json.default</span></tt>
and name it <tt class="docutils literal"><span class="pre">config.json</span></tt></li>
<li>Change the configuration file as necessary; see <a class="reference internal" href="#lsconfig"><em>Configuration file</em></a>.</li>
<li>Run the server by executing <tt class="docutils literal"><span class="pre">python3</span> <span class="pre">src/lightserver.py</span></tt>
from the folder where you just created the configuration file.</li>
</ol>
</div>
<div class="section" id="configuration-file">
<span id="lsconfig"></span><h3>Configuration file<a class="headerlink" href="#configuration-file" title="Permalink to this headline">¶</a></h3>
<p>The configuration file uses JSON syntax.
The configuration itself is a JSON object with various properties, as listed here:</p>
<table border="1" class="docutils">
<colgroup>
<col width="30%" />
<col width="22%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Allowed values</th>
<th class="head">Meaning</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>port</td>
<td>Integer, 0-65535</td>
<td>Server port number (default: 4711).</td>
</tr>
<tr class="row-odd"><td>password</td>
<td>Text string</td>
<td>Server password.</td>
</tr>
<tr class="row-even"><td>require_password</td>
<td>Boolean</td>
<td>If true, the server will require a password;
see <a class="reference internal" href="#authentication"><em>Authentication</em></a>.</td>
</tr>
<tr class="row-odd"><td>validate_state_changes</td>
<td>Boolean</td>
<td>If true, the server will validate values and
parameters when changing the state of lights.
Setting this value to false can be useful
in cases where the internal validation schema
is outdated, though it may lead to unexpected
results.</td>
</tr>
<tr class="row-even"><td>ssl</td>
<td>Boolean</td>
<td>If true, the server will communicate with
the application using HTTPS.</td>
</tr>
<tr class="row-odd"><td>certfile</td>
<td>String, path to file</td>
<td>If SSL is enabled, this file will
be used as the SSL certificate.</td>
</tr>
<tr class="row-even"><td>keyfile</td>
<td>String, path to file</td>
<td>If SSL is enabled, this file will
be used as the SSL private key.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="the-api">
<span id="api"></span><h2>The API<a class="headerlink" href="#the-api" title="Permalink to this headline">¶</a></h2>
<p>This is a REST-inspired API that simplifies communication with Philips Hue bridges.</p>
<p>The API abstracts access to individual bridges by placing each light associated with a bridge
into a virtual grid, after which lights can be addressed by specifying the <tt class="docutils literal"><span class="pre">(x,</span> <span class="pre">y)</span></tt> coordinate
of the light in the grid, without having to take into account which bridge the light belongs to.</p>
<p>A number of API methods expect the request body to contain well-formed JSON conforming to
a certain format which differs between methods. This format is specified using JSON Schema; see
<a class="reference external" href="http://json-schema.org/">the official website</a> for more information and
<a class="reference external" href="http://spacetelescope.github.io/understanding-json-schema/">Understanding JSON Schema</a> for
a friendlier introduction.</p>
<div class="section" id="responses">
<h3>Responses<a class="headerlink" href="#responses" title="Permalink to this headline">¶</a></h3>
<p>All responses from the API will be a well-formed JSON object containing at the very least
a <tt class="docutils literal"><span class="pre">state</span></tt> property with either the string <tt class="docutils literal"><span class="pre">success</span></tt> or <tt class="docutils literal"><span class="pre">error</span></tt>. Unless otherwise specified,
any successful responses will contain only <tt class="docutils literal"><span class="pre">{"state":</span> <span class="pre">"success"}</span></tt>.</p>
</div>
<div class="section" id="failed-requests">
<h3>Failed requests<a class="headerlink" href="#failed-requests" title="Permalink to this headline">¶</a></h3>
<p>If a request fails, the response will contain an object with the poperty <tt class="docutils literal"><span class="pre">state</span></tt> set to the
string <tt class="docutils literal"><span class="pre">error</span></tt>. Additionally the property <tt class="docutils literal"><span class="pre">errorcode</span></tt> will contain a short string identifying
the error type, and the property <tt class="docutils literal"><span class="pre">errormessage</span></tt> a human-readable error message.</p>
</div>
<div class="section" id="authentication">
<span id="id1"></span><h3>Authentication<a class="headerlink" href="#authentication" title="Permalink to this headline">¶</a></h3>
<p>TODO</p>
</div>
<div class="section" id="api-methods">
<h3>API methods<a class="headerlink" href="#api-methods" title="Permalink to this headline">¶</a></h3>
<dl class="post">
<dt id="post--lights">
<tt class="descname">POST </tt><tt class="descname">/lights</tt><a class="headerlink" href="#post--lights" title="Permalink to this definition">¶</a></dt>
<dd><p>Change the state of the lights at the given coordinates.</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">[</span>
<span class="p">{</span>
<span class="nt">"x"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"y"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">"change"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"hue"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"sat"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"bri"</span><span class="p">:</span> <span class="mi">100</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"x"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">"y"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">"delay"</span><span class="p">:</span> <span class="mf">0.8</span><span class="p">,</span>
<span class="nt">"change"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"xy"</span><span class="p">:</span> <span class="p">[</span><span class="mf">0.2</span><span class="p">,</span> <span class="mf">0.4</span><span class="p">],</span>
<span class="nt">"transitiontime"</span><span class="p">:</span> <span class="mi">10</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">]</span>
</pre></div>
</div>
<p><strong>Expected JSON format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"items"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"change"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"alert"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"none"</span><span class="p">,</span>
<span class="s2">"select"</span><span class="p">,</span>
<span class="s2">"lselect"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"bri"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"ct"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">500</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">153</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"effect"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"none"</span><span class="p">,</span>
<span class="s2">"colorloop"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"hue"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">65535</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"on"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"boolean"</span>
<span class="p">},</span>
<span class="nt">"rgb"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"items"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"number"</span>
<span class="p">},</span>
<span class="nt">"maxItems"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">"minItems"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"array"</span>
<span class="p">},</span>
<span class="nt">"sat"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"transitiontime"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"xy"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"items"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"number"</span>
<span class="p">},</span>
<span class="nt">"maxItems"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">"minItems"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"array"</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span>
<span class="p">},</span>
<span class="nt">"delay"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"number"</span>
<span class="p">},</span>
<span class="nt">"x"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"y"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="nt">"required"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"x"</span><span class="p">,</span>
<span class="s2">"y"</span><span class="p">,</span>
<span class="s2">"change"</span>
<span class="p">],</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span>
<span class="p">},</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"array"</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>
<dl class="post">
<dt id="post--lights-all">
<tt class="descname">POST </tt><tt class="descname">/lights/all</tt><a class="headerlink" href="#post--lights-all" title="Permalink to this definition">¶</a></dt>
<dd><p>Set all lights known by all bridges added to the grid to the same state.</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span><span class="nt">"on"</span><span class="p">:</span> <span class="kc">false</span><span class="p">}</span>
</pre></div>
</div>
<p><strong>Expected JSON format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"alert"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"none"</span><span class="p">,</span>
<span class="s2">"select"</span><span class="p">,</span>
<span class="s2">"lselect"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"bri"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"ct"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">500</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">153</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"effect"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"none"</span><span class="p">,</span>
<span class="s2">"colorloop"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"hue"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">65535</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"on"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"boolean"</span>
<span class="p">},</span>
<span class="nt">"rgb"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"items"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"number"</span>
<span class="p">},</span>
<span class="nt">"maxItems"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">"minItems"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"array"</span>
<span class="p">},</span>
<span class="nt">"sat"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"transitiontime"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"xy"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"items"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"number"</span>
<span class="p">},</span>
<span class="nt">"maxItems"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">"minItems"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"array"</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>
<dl class="get">
<dt id="get--bridges">
<tt class="descname">GET </tt><tt class="descname">/bridges</tt><a class="headerlink" href="#get--bridges" title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve a list of all bridges added to the grid.</p>
<p><em>The request body is ignored by this method.</em></p>
<p><strong>Example response</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"state"</span><span class="p">:</span> <span class="s2">"success"</span><span class="p">,</span>
<span class="nt">"bridges"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"cd3facebd076"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"ip"</span><span class="p">:</span> <span class="s2">"192.168.0.101"</span><span class="p">,</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">"valid_username"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="nt">"lights"</span><span class="p">:</span> <span class="mi">-1</span>
<span class="p">},</span>
<span class="nt">"f827aef865ca"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"ip"</span><span class="p">:</span> <span class="s2">"192.168.0.104"</span><span class="p">,</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="s2">"my-username"</span><span class="p">,</span>
<span class="nt">"valid_username"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nt">"lights"</span><span class="p">:</span> <span class="mi">3</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p><strong>Successful response format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span><span class="p">,</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"state"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"success"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"bridges"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"Map of MAC address -> bridge information key/value pairs."</span><span class="p">,</span>
<span class="nt">"patternProperties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"[0-9a-f]{12}"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span><span class="p">,</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"ip"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"The IP address of the bridge."</span>
<span class="p">},</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"The username used with the bridge."</span>
<span class="p">},</span>
<span class="nt">"valid_username"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"boolean"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"Whether the username is valid for use with the bridge."</span>
<span class="p">},</span>
<span class="nt">"lights"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"Number of lights belonging to the bridge. -1 if valid_username is false."</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>
<dl class="post">
<dt id="post--bridges-add">
<tt class="descname">POST </tt><tt class="descname">/bridges/add</tt><a class="headerlink" href="#post--bridges-add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a new bridge with the given IP address and username.</p>
<p>A username is not required and may be either given as <tt class="docutils literal"><span class="pre">null</span></tt> or not supplied at all,
though without one most actions involving the bridge will fail.</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"ip"</span><span class="p">:</span> <span class="s2">"192.168.0.104"</span><span class="p">,</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="s2">"my-username"</span>
<span class="p">}</span>
</pre></div>
</div>
<p><strong>Expected JSON format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"ip"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span>
<span class="p">},</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"anyOf"</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"null"</span>
<span class="p">}</span>
<span class="p">]</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="nt">"required"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"ip"</span>
<span class="p">],</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span>
<span class="p">}</span>
</pre></div>
</div>
<p><strong>Example response</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"state"</span><span class="p">:</span> <span class="s2">"success"</span><span class="p">,</span>
<span class="nt">"bridges"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"f827aef865ca"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"ip"</span><span class="p">:</span> <span class="s2">"192.168.0.104"</span><span class="p">,</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="s2">"my-username"</span><span class="p">,</span>
<span class="nt">"valid_username"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nt">"lights"</span><span class="p">:</span> <span class="mi">3</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p><strong>Successful response format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span><span class="p">,</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"state"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"success"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"bridges"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"Map of MAC address -> bridge information key/value pairs."</span><span class="p">,</span>
<span class="nt">"maxProperties"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">"patternProperties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"[0-9a-f]{12}"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span><span class="p">,</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"ip"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"The IP address of the bridge."</span>
<span class="p">},</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"The username used with the bridge."</span>
<span class="p">},</span>
<span class="nt">"valid_username"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"boolean"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"Whether the username is valid for use with the bridge."</span>
<span class="p">},</span>
<span class="nt">"lights"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"Number of lights belonging to the bridge. -1 if valid_username is false."</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>
<dl class="get">
<dt id="get--bridges-search">
<tt class="descname">GET </tt><tt class="descname">/bridges/search</tt><a class="headerlink" href="#get--bridges-search" title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve bridges found after running <a class="reference internal" href="#post--bridges-search" title="POST /bridges/search"><tt class="xref http http-post docutils literal"><span class="pre">POST</span> <span class="pre">/bridges/search</span></tt></a>.</p>
<p><em>The request body is ignored by this method.</em></p>
<p><strong>Example response</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"state"</span><span class="p">:</span> <span class="s2">"success"</span><span class="p">,</span>
<span class="nt">"finished"</span><span class="p">:</span> <span class="mi">1400776113</span><span class="p">,</span>
<span class="nt">"bridges"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"0fb2a8549ec2"</span><span class="p">:</span> <span class="s2">"192.168.0.105"</span><span class="p">,</span>
<span class="nt">"92d0d3cdbc7f"</span><span class="p">:</span> <span class="s2">"192.168.0.109"</span><span class="p">,</span>
<span class="nt">"e2fa9cc7df08"</span><span class="p">:</span> <span class="s2">"192.168.0.103"</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p><strong>Successful response format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span><span class="p">,</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"state"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"success"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"finished"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"UNIX timestamp indicating when a search last finished. -1 if no search has been issued yet."</span>
<span class="p">},</span>
<span class="nt">"bridges"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"patternProperties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"[0-9a-f]{12}"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"The IP address of the bridge."</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>
<dl class="post">
<dt id="post--bridges-search">
<tt class="descname">POST </tt><tt class="descname">/bridges/search</tt><a class="headerlink" href="#post--bridges-search" title="Permalink to this definition">¶</a></dt>
<dd><p>Search for bridges on the local network.</p>
<p>Returns immediately and runs the search asynchronously. To see when the search has
finished and retrieve the new bridges, issue a request to
<a class="reference internal" href="#get--bridges-search" title="GET /bridges/search"><tt class="xref http http-get docutils literal"><span class="pre">GET</span> <span class="pre">/bridges/search</span></tt></a> periodically.</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span><span class="nt">"auto_add"</span><span class="p">:</span> <span class="kc">true</span><span class="p">}</span>
</pre></div>
</div>
<p><strong>Expected JSON format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"auto_add"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"If true, new bridges are automatically added to the grid."</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"boolean"</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="nt">"required"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"auto_add"</span>
<span class="p">],</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>
<dl class="post">
<dt id="post--bridges-(?P-mac-[0-9a-f]{12})">
<tt class="descname">POST </tt><tt class="descname">/bridges/(?P<mac>[0-9a-f]{12})</tt><a class="headerlink" href="#post--bridges-(?P-mac-[0-9a-f]{12})" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the username to use for this bridge.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mac</strong> – The MAC address of the bridge whose username to change.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><strong>Example request</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span><span class="nt">"username"</span><span class="p">:</span> <span class="s2">"my-username"</span><span class="p">}</span>
</pre></div>
</div>
<p><strong>Expected JSON format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"anyOf"</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"null"</span>
<span class="p">}</span>
<span class="p">]</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="nt">"required"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"username"</span>
<span class="p">],</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span>
<span class="p">}</span>
</pre></div>
</div>
<p><strong>Example response</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span><span class="nt">"username"</span><span class="p">:</span> <span class="s2">"myusername"</span><span class="p">,</span> <span class="nt">"valid_username"</span><span class="p">:</span> <span class="kc">true</span><span class="p">}</span>
</pre></div>
</div>
<p><strong>Successful response format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span><span class="p">,</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"state"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"success"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"anyOf"</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"null"</span><span class="p">,</span>
<span class="p">}</span>
<span class="p">],</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"The new username."</span>
<span class="p">},</span>
<span class="nt">"valid_username"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"boolean"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"Whether the username is valid for use with the bridge."</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>
<dl class="delete">
<dt id="delete--bridges-(?P-mac-[0-9a-f]{12})">
<tt class="descname">DELETE </tt><tt class="descname">/bridges/(?P<mac>[0-9a-f]{12})</tt><a class="headerlink" href="#delete--bridges-(?P-mac-[0-9a-f]{12})" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove this bridge from the grid.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mac</strong> – The MAC address of the bridge to remove.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><em>The request body is ignored by this method.</em></p>
</dd></dl>
<dl class="post">
<dt id="post--bridges-(?P-mac-[0-9a-f]{12})-adduser">
<tt class="descname">POST </tt><tt class="descname">/bridges/(?P<mac>[0-9a-f]{12})/adduser</tt><a class="headerlink" href="#post--bridges-(?P-mac-[0-9a-f]{12})-adduser" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new username for use with this bridge.</p>
<p>If a username is not supplied, a new one will be generated by the bridge. The link button
on the bridge must be pressed prior to issuing a request.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mac</strong> – The MAC address of the bridge for which to create the new username.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><strong>Example request</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{}</span>
</pre></div>
</div>
<p><strong>Expected JSON format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span>
<span class="p">}</span>
</pre></div>
</div>
<p><strong>Example response</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"state"</span><span class="p">:</span> <span class="s2">"success"</span><span class="p">,</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="s2">"f321c5d40b3a79eed6adc08eb3997a5e"</span><span class="p">,</span>
<span class="nt">"valid_username"</span><span class="p">:</span> <span class="kc">true</span>
<span class="p">}</span>
</pre></div>
</div>
<p><strong>Successful response format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span><span class="p">,</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"state"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"success"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"username"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"The new username."</span>
<span class="p">},</span>
<span class="nt">"valid_username"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"boolean"</span><span class="p">,</span>
<span class="nt">"description"</span><span class="p">:</span> <span class="s2">"Whether the username is valid for use with the bridge (always true)."</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>
<dl class="post">
<dt id="post--bridges-(?P-mac-[0-9a-f]{12})-lights">
<tt class="descname">POST </tt><tt class="descname">/bridges/(?P<mac>[0-9a-f]{12})/lights</tt><a class="headerlink" href="#post--bridges-(?P-mac-[0-9a-f]{12})-lights" title="Permalink to this definition">¶</a></dt>
<dd><p>Change the state of the given lights known by this bridge.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mac</strong> – The MAC address of the bridge that the lights whose state to change belong to.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><strong>Example request</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">[</span>
<span class="p">{</span>
<span class="nt">"light"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">"change"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"hue"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"sat"</span><span class="p">:</span> <span class="mi">255</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"light"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">"change"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"hue"</span><span class="p">:</span> <span class="mi">21845</span><span class="p">,</span>
<span class="nt">"sat"</span><span class="p">:</span> <span class="mi">255</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"light"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">"change"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"hue"</span><span class="p">:</span> <span class="mi">43690</span><span class="p">,</span>
<span class="nt">"sat"</span><span class="p">:</span> <span class="mi">255</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="p">]</span>
</pre></div>
</div>
<p><strong>Expected JSON format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"items"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"change"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"alert"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"none"</span><span class="p">,</span>
<span class="s2">"select"</span><span class="p">,</span>
<span class="s2">"lselect"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"bri"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"ct"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">500</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">153</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"effect"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"none"</span><span class="p">,</span>
<span class="s2">"colorloop"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"hue"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">65535</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"on"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"boolean"</span>
<span class="p">},</span>
<span class="nt">"rgb"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"items"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"number"</span>
<span class="p">},</span>
<span class="nt">"maxItems"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">"minItems"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"array"</span>
<span class="p">},</span>
<span class="nt">"sat"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"transitiontime"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"xy"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"items"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"number"</span>
<span class="p">},</span>
<span class="nt">"maxItems"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">"minItems"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"array"</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span>
<span class="p">},</span>
<span class="nt">"light"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="nt">"required"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"light"</span><span class="p">,</span>
<span class="s2">"change"</span>
<span class="p">],</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span>
<span class="p">},</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"array"</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>
<dl class="post">
<dt id="post--bridges-(?P-mac-[0-9a-f]{12})-lights-all">
<tt class="descname">POST </tt><tt class="descname">/bridges/(?P<mac>[0-9a-f]{12})/lights/all</tt><a class="headerlink" href="#post--bridges-(?P-mac-[0-9a-f]{12})-lights-all" title="Permalink to this definition">¶</a></dt>
<dd><p>Change the state of all lights known by this bridge.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mac</strong> – The MAC address of the bridge that the lights whose state to change belong to.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><strong>Example request</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span><span class="nt">"alert"</span><span class="p">:</span> <span class="s2">"select"</span><span class="p">}</span>
</pre></div>
</div>
<p><strong>Expected JSON format</strong>:</p>
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
<span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"alert"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"none"</span><span class="p">,</span>
<span class="s2">"select"</span><span class="p">,</span>
<span class="s2">"lselect"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"bri"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"ct"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">500</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">153</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"effect"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"enum"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"none"</span><span class="p">,</span>
<span class="s2">"colorloop"</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">"hue"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">65535</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"on"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"boolean"</span>
<span class="p">},</span>
<span class="nt">"rgb"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"items"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"number"</span>
<span class="p">},</span>
<span class="nt">"maxItems"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">"minItems"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"array"</span>
<span class="p">},</span>
<span class="nt">"sat"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">255</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"transitiontime"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"integer"</span>
<span class="p">},</span>
<span class="nt">"xy"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"items"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"maximum"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">"minimum"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"number"</span>
<span class="p">},</span>
<span class="nt">"maxItems"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">"minItems"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"array"</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>
<dl class="post">
<dt id="post--bridges-(?P-mac-[0-9a-f]{12})-lampsearch">
<tt class="descname">POST </tt><tt class="descname">/bridges/(?P<mac>[0-9a-f]{12})/lampsearch</tt><a class="headerlink" href="#post--bridges-(?P-mac-[0-9a-f]{12})-lampsearch" title="Permalink to this definition">¶</a></dt>
<dd><p>Search for nearby lights for one minute and add them to this bridge.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mac</strong> – The MAC address of the bridge that is to commence the search.</li>