-
Notifications
You must be signed in to change notification settings - Fork 0
/
playhouse.html
910 lines (861 loc) · 81.5 KB
/
playhouse.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
<!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>playhouse — Python library for communicating with 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="lightserver — Server exposing an HTTP API for controlling several Philips Hue bridges" href="lightserver.html" />
<link rel="prev" title="Light server" href="backend.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="lightserver.html" title="lightserver — Server exposing an HTTP API for controlling several Philips Hue bridges"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="backend.html" title="Light server"
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-playhouse">
<span id="playhouse-python-library-for-communicating-with-philips-hue-bridges"></span><h1><a class="reference internal" href="#module-playhouse" title="playhouse"><tt class="xref py py-mod docutils literal"><span class="pre">playhouse</span></tt></a> — Python library for communicating with Philips Hue bridges<a class="headerlink" href="#module-playhouse" title="Permalink to this headline">¶</a></h1>
<p>A <a class="reference external" href="http://www.tornadoweb.org/">Tornado</a>-based Python library for communicating
with Philips Hue bridges.</p>
<p>This library exposes the Philips Hue API, normally a JSON API, as an object oriented Python API.
These methods require that the <a class="reference external" href="http://www.tornadoweb.org/en/stable/ioloop.html#tornado.ioloop.IOLoop" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">IOLoop</span></tt></a> returned by <a class="reference external" href="http://www.tornadoweb.org/en/stable/ioloop.html#tornado.ioloop.IOLoop.current" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.ioloop.IOLoop.current</span></tt></a>
is running in order to function.</p>
<div class="section" id="bridge-management">
<h2>Bridge management<a class="headerlink" href="#bridge-management" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="playhouse.Bridge">
<em class="property">class </em><tt class="descclassname">playhouse.</tt><tt class="descname">Bridge</tt><a class="reference internal" href="_modules/playhouse.html#Bridge"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge" title="Permalink to this definition">¶</a></dt>
<dd><p>Instances of the Bridge handle a connection to a specific Hue bridge.</p>
<p>Hue bridges communicate through a RESTful JSON API through TCP port 80.
This class wraps this RESTful interface and provides a Python API for
convenient Hue bridge operation. The functions for setting the current
state of a particular lamp use the Hue light state names, see
<a class="reference external" href="http://developers.meethue.com/1_lightsapi.html#16_set_light_state">http://developers.meethue.com/1_lightsapi.html#16_set_light_state</a> for reference.</p>
<dl class="staticmethod">
<dt id="playhouse.Bridge.__new__">
<em class="property">static </em><tt class="descname">__new__</tt><big>(</big><em>ipaddress</em>, <em>username=None</em>, <em>defaults=None</em>, <em>timeout=2</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.__new__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.__new__" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new Bridge object. Example usage:</p>
<div class="highlight-py3"><div class="highlight"><pre><span class="nd">@tornado</span><span class="o">.</span><span class="n">gen</span><span class="o">.</span><span class="n">coroutine</span>
<span class="k">def</span> <span class="nf">turn_off_lights</span><span class="p">():</span>
<span class="n">future</span> <span class="o">=</span> <span class="n">Bridge</span><span class="p">(</span><span class="s">"192.168.0.105"</span><span class="p">,</span> <span class="n">username</span><span class="o">=</span><span class="s">"mysecretusername"</span><span class="p">,</span>
<span class="n">defaults</span><span class="o">=</span><span class="p">{</span><span class="s">"transitiontime"</span><span class="p">:</span> <span class="mi">10</span><span class="p">})</span>
<span class="n">bridge</span> <span class="o">=</span> <span class="k">yield</span> <span class="n">future</span>
<span class="k">yield</span> <span class="n">bridge</span><span class="o">.</span><span class="n">set_group</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">on</span><span class="o">=</span><span class="k">False</span><span class="p">})</span>
<span class="n">ioloop</span><span class="o">.</span><span class="n">run_sync</span><span class="p">(</span><span class="n">turn_off_lights</span><span class="p">)</span>
</pre></div>
</div>
<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 simple">
<li><strong>ipaddress</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – The IP address for this bridge</li>
<li><strong>username</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – The username for this bridge as described in the Hue documentation.
Required for most commands.</li>
<li><strong>defaults</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><em>dict</em></a>) – A dictionary containing default state changes to be sent with any
state-changing commands.</li>
<li><strong>timeout</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><em>int</em></a>) – The time in seconds to wait for any requests to the Hue bridge
to complete.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to a bridge object when completed.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><tt class="xref py py-exc docutils literal"><span class="pre">NoBridgeFoundException</span></tt> if no bridge was found at the given IP address.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="playhouse.Bridge.ipaddress">
<tt class="descname">ipaddress</tt><a class="headerlink" href="#playhouse.Bridge.ipaddress" title="Permalink to this definition">¶</a></dt>
<dd><p>The IP address of the bridge.</p>
</dd></dl>
<dl class="attribute">
<dt id="playhouse.Bridge.serial_number">
<tt class="descname">serial_number</tt><a class="headerlink" href="#playhouse.Bridge.serial_number" title="Permalink to this definition">¶</a></dt>
<dd><p>The serial number of the bridge. This is the same as the MAC address.</p>
</dd></dl>
<dl class="attribute">
<dt id="playhouse.Bridge.username">
<tt class="descname">username</tt><a class="headerlink" href="#playhouse.Bridge.username" title="Permalink to this definition">¶</a></dt>
<dd><p>The current username.</p>
</dd></dl>
<dl class="attribute">
<dt id="playhouse.Bridge.logged_in">
<tt class="descname">logged_in</tt><a class="headerlink" href="#playhouse.Bridge.logged_in" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference external" href="http://docs.python.org/3/library/constants.html#True" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt></a> if the current username is valid for use with the bridge, <a class="reference external" href="http://docs.python.org/3/library/constants.html#False" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">False</span></tt></a> otherwise.
This value is updated by <a class="reference internal" href="#playhouse.Bridge.update_info" title="playhouse.Bridge.update_info"><tt class="xref py py-obj docutils literal"><span class="pre">update_info</span></tt></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="playhouse.Bridge.name">
<tt class="descname">name</tt><a class="headerlink" href="#playhouse.Bridge.name" title="Permalink to this definition">¶</a></dt>
<dd><p>The UPnP name of this bridge. Will be <a class="reference external" href="http://docs.python.org/3/library/constants.html#None" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt></a> until successfully updated by <a class="reference internal" href="#playhouse.Bridge.update_info" title="playhouse.Bridge.update_info"><tt class="xref py py-obj docutils literal"><span class="pre">update_info</span></tt></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="playhouse.Bridge.mac">
<tt class="descname">mac</tt><a class="headerlink" href="#playhouse.Bridge.mac" title="Permalink to this definition">¶</a></dt>
<dd><p>The MAC address as reported by the bridge. Will be <a class="reference external" href="http://docs.python.org/3/library/constants.html#None" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt></a> until successfully updated by
<a class="reference internal" href="#playhouse.Bridge.update_info" title="playhouse.Bridge.update_info"><tt class="xref py py-obj docutils literal"><span class="pre">update_info</span></tt></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="playhouse.Bridge.gateway">
<tt class="descname">gateway</tt><a class="headerlink" href="#playhouse.Bridge.gateway" title="Permalink to this definition">¶</a></dt>
<dd><p>The gateway of this bridge. Will be <a class="reference external" href="http://docs.python.org/3/library/constants.html#None" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt></a> until successfully updated by <a class="reference internal" href="#playhouse.Bridge.update_info" title="playhouse.Bridge.update_info"><tt class="xref py py-obj docutils literal"><span class="pre">update_info</span></tt></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="playhouse.Bridge.netmask">
<tt class="descname">netmask</tt><a class="headerlink" href="#playhouse.Bridge.netmask" title="Permalink to this definition">¶</a></dt>
<dd><p>The netmask of this bridge. Will be <a class="reference external" href="http://docs.python.org/3/library/constants.html#None" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt></a> until successfully updated by <a class="reference internal" href="#playhouse.Bridge.update_info" title="playhouse.Bridge.update_info"><tt class="xref py py-obj docutils literal"><span class="pre">update_info</span></tt></a>.</p>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.http_request">
<tt class="descname">http_request</tt><big>(</big><em>method</em>, <em>url</em>, <em>body=None</em>, <em>timeout=None</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.http_request"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.http_request" title="Permalink to this definition">¶</a></dt>
<dd><p>Send an HTTP request to the 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 simple">
<li><strong>method</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – HTTP request method (POST/GET/PUT/DELETE)</li>
<li><strong>url</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – The URL to send this request to.</li>
<li><strong>body</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – HTTP POST request body.</li>
<li><strong>timeout</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><em>int</em></a>) – The time to wait for this request to complete. Defaults to
the timeout supplied to the <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> constructor.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the response from the bridge
when complete.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPResponse" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPResponse</span></tt></a> if the HTTP request failed.</p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.send_raw">
<tt class="descname">send_raw</tt><big>(</big><em>method</em>, <em>url</em>, <em>body=None</em>, <em>timeout=None</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.send_raw"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.send_raw" title="Permalink to this definition">¶</a></dt>
<dd><p>Send an HTTP request to the bridge, automatically parsing the returned JSON.</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 simple">
<li><strong>method</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – HTTP request method (POST/GET/PUT/DELETE).</li>
<li><strong>url</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – The URL to send this request to.</li>
<li><strong>body</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><em>dict</em></a>) – HTTP POST request body as a Python dictionary. The dictionary
will be converted to a JSON string.</li>
<li><strong>timeout</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><em>int</em></a>) – The time to wait for this request to complete. Defaults to
the timeout supplied to the <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> constructor.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the response from the bridge,
converted from JSON to a Python dictionary, when complete.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">dict</span></tt></a></p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.send_request">
<tt class="descname">send_request</tt><big>(</big><em>method</em>, <em>url</em>, <em>body=None</em>, <em>timeout=None</em>, <em>force_send=False</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.send_request"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.send_request" title="Permalink to this definition">¶</a></dt>
<dd><p>Send an HTTP request to the bridge using this <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> instance’s <a class="reference internal" href="#playhouse.Bridge.username" title="playhouse.Bridge.username"><tt class="xref py py-obj docutils literal"><span class="pre">username</span></tt></a>.</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 simple">
<li><strong>method</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – HTTP request method (POST/GET/PUT/DELETE).</li>
<li><strong>url</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – The URL to send this request to. <tt class="docutils literal"><span class="pre">/api/</span></tt> followed by the username
is automatically prepended to the URL.</li>
<li><strong>body</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><em>dict</em></a>) – HTTP POST request body as a Python dictionary. The dictionary
will be converted to a JSON string.</li>
<li><strong>timeout</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><em>int</em></a>) – The time to wait for this request to complete. Defaults to
the timeout supplied to the <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> constructor.</li>
<li><strong>force_send</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#bool" title="(in Python v3.4)"><em>bool</em></a>) – By default no request will be attempted and an
<tt class="xref py py-obj docutils literal"><span class="pre">UnauthorizedUserException</span></tt> will be raised if no username is set;
setting this parameter to <a class="reference external" href="http://docs.python.org/3/library/constants.html#True" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt></a> will force a request using
a dummy username (<tt class="docutils literal"><span class="pre">none</span></tt>).</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the response from the bridge,
converted from JSON to a Python dictionary, when complete.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">dict</span></tt></a></p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.set_state">
<tt class="descname">set_state</tt><big>(</big><em>i</em>, <em>**args</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.set_state"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.set_state" title="Permalink to this definition">¶</a></dt>
<dd><p>Set state of a particular lamp.</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 simple">
<li><strong>i</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><em>int</em></a>) – ID number for the light whose state to change.</li>
<li><strong>args</strong> – Hue state changes. A full list of allowed state change can be found at
<a class="reference external" href="http://developers.meethue.com/1_lightsapi.html#16_set_light_state">http://developers.meethue.com/1_lightsapi.html#16_set_light_state</a>.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the response from the bridge,
converted from JSON to a Python dictionary, when complete.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">dict</span></tt></a></p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.set_group">
<tt class="descname">set_group</tt><big>(</big><em>i</em>, <em>**args</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.set_group"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.set_group" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the state of a given lamp group.</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 simple">
<li><strong>i</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><em>int</em></a>) – ID for the group whose state to change.</li>
<li><strong>args</strong> – Hue state changes. A full list of allowed state changes can be found at
<a class="reference external" href="http://developers.meethue.com/1_lightsapi.html#16_set_light_state">http://developers.meethue.com/1_lightsapi.html#16_set_light_state</a>.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the response from the bridge,
converted from JSON to a Python dictionary, when complete.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">dict</span></tt></a></p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.create_group">
<tt class="descname">create_group</tt><big>(</big><em>lights</em>, <em>name=None</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.create_group"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.create_group" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new group 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 simple">
<li><strong>lights</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.4)"><em>list</em></a>) – a list of lamp IDs (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">int</span></tt></a>).</li>
<li><strong>name</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – Name for this group, optional argument.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the response from the bridge,
converted from JSON to a Python dictionary, when complete.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">dict</span></tt></a></p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.delete_group">
<tt class="descname">delete_group</tt><big>(</big><em>i</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.delete_group"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.delete_group" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete a new group from 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"><p class="first"><strong>i</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><em>int</em></a>) – ID number for the group to be removed.</p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the response from the bridge,
converted from JSON to a Python dictionary, when complete.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">dict</span></tt></a></p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.get_lights">
<tt class="descname">get_lights</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.get_lights"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.get_lights" title="Permalink to this definition">¶</a></dt>
<dd><p>Fetch a list of all lights known to the 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">Returns:</th><td class="field-body">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the response from the bridge,
converted from JSON to a Python dictionary, when complete.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">dict</span></tt></a></td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.
<a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.search_lights">
<tt class="descname">search_lights</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.search_lights"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.search_lights" title="Permalink to this definition">¶</a></dt>
<dd><p>Start a new light search.</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">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the response from the bridge,
converted from JSON to a Python dictionary, when complete.</p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">dict</span></tt></a></p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.get_new_lights">
<tt class="descname">get_new_lights</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.get_new_lights"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.get_new_lights" title="Permalink to this definition">¶</a></dt>
<dd><p>Get a list of all lights found after running <a class="reference internal" href="#playhouse.Bridge.search_lights" title="playhouse.Bridge.search_lights"><tt class="xref py py-obj docutils literal"><span class="pre">search_lights</span></tt></a>.</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">Returns:</th><td class="field-body">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the response from the bridge,
converted from JSON to a Python dictionary, when complete.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">dict</span></tt></a></td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.
<a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.get_bridge_info">
<tt class="descname">get_bridge_info</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.get_bridge_info"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.get_bridge_info" title="Permalink to this definition">¶</a></dt>
<dd><p>TODO TODO TODO</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">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the response from the bridge,
converted from JSON to a Python dictionary, when complete.</p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">dict</span></tt></a></p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.create_user">
<tt class="descname">create_user</tt><big>(</big><em>devicetype</em>, <em>username=None</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.create_user"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.create_user" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new user for this bridge.</p>
<p>A valid user name is required to execute most commands. In order to create a new user,
the link button on the Hue bridge must be pressed before this command is executed.</p>
<p><a class="reference internal" href="#playhouse.Bridge.update_info" title="playhouse.Bridge.update_info"><tt class="xref py py-obj docutils literal"><span class="pre">update_info</span></tt></a> will be called automatically after setting the username.</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 simple">
<li><strong>devicetype</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – The ‘type’ of user. Should be related to the application
for which this user is created.</li>
<li><strong>username</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – The new user name. If not supplied a random user name will
be generated by the bridge.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the new username when complete.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">str</span></tt></a></p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
<p><tt class="xref py py-obj docutils literal"><span class="pre">NoLinkButtonPressedException</span></tt> if the link button was not pressed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.set_username">
<tt class="descname">set_username</tt><big>(</big><em>username</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.set_username"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.set_username" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the user name for this bridge.</p>
<p>A valid user name is required to execute most commands.</p>
<p><a class="reference internal" href="#playhouse.Bridge.update_info" title="playhouse.Bridge.update_info"><tt class="xref py py-obj docutils literal"><span class="pre">update_info</span></tt></a> will be automatically after setting the username.</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"><p class="first"><strong>username</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – The new user name.</p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that completes when <a class="reference internal" href="#playhouse.Bridge.update_info" title="playhouse.Bridge.update_info"><tt class="xref py py-obj docutils literal"><span class="pre">update_info</span></tt></a> has finished
updating the metadata.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.set_defaults">
<tt class="descname">set_defaults</tt><big>(</big><em>defaults</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.set_defaults"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.set_defaults" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the default state changes to be included with any calls to state-changing operations.</p>
<p>These changes are included whenever the state is set, unless overridden
by the provided state change argument.</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"><strong>defaults</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><em>dict</em></a>) – The new default state changes.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.update_info">
<tt class="descname">update_info</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.update_info"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.update_info" title="Permalink to this definition">¶</a></dt>
<dd><p>Update the Hue bridge metadata.</p>
<p>If the current <a class="reference internal" href="#playhouse.Bridge.username" title="playhouse.Bridge.username"><tt class="xref py py-obj docutils literal"><span class="pre">username</span></tt></a> is valid, <a class="reference internal" href="#playhouse.Bridge.logged_in" title="playhouse.Bridge.logged_in"><tt class="xref py py-obj docutils literal"><span class="pre">logged_in</span></tt></a> will be set to <a class="reference external" href="http://docs.python.org/3/library/constants.html#True" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt></a> and
<a class="reference internal" href="#playhouse.Bridge.gateway" title="playhouse.Bridge.gateway"><tt class="xref py py-obj docutils literal"><span class="pre">gateway</span></tt></a>, <a class="reference internal" href="#playhouse.Bridge.netmask" title="playhouse.Bridge.netmask"><tt class="xref py py-obj docutils literal"><span class="pre">netmask</span></tt></a>, <a class="reference internal" href="#playhouse.Bridge.name" title="playhouse.Bridge.name"><tt class="xref py py-obj docutils literal"><span class="pre">name</span></tt></a> and <a class="reference internal" href="#playhouse.Bridge.mac" title="playhouse.Bridge.mac"><tt class="xref py py-obj docutils literal"><span class="pre">mac</span></tt></a> will be updated; otherwise, <a class="reference internal" href="#playhouse.Bridge.logged_in" title="playhouse.Bridge.logged_in"><tt class="xref py py-obj docutils literal"><span class="pre">logged_in</span></tt></a>
will be set to <a class="reference external" href="http://docs.python.org/3/library/constants.html#False" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">False</span></tt></a> and the remaining attributes to <a class="reference external" href="http://docs.python.org/3/library/constants.html#None" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt></a>.</p>
<p>This method is called automatically by <a class="reference internal" href="#playhouse.Bridge.create_user" title="playhouse.Bridge.create_user"><tt class="xref py py-obj docutils literal"><span class="pre">create_user</span></tt></a> and <a class="reference internal" href="#playhouse.Bridge.set_username" title="playhouse.Bridge.set_username"><tt class="xref py py-obj docutils literal"><span class="pre">set_username</span></tt></a>.</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">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that completes when the update attempt completes.</p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.Bridge.reset_nearby_bulb">
<tt class="descname">reset_nearby_bulb</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/playhouse.html#Bridge.reset_nearby_bulb"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.Bridge.reset_nearby_bulb" title="Permalink to this definition">¶</a></dt>
<dd><p>Attempts to reset a Hue light bulb in proximity to the bridge.</p>
<p>For best effect, place the bulb in close proximity to the bridge, and make
sure that there are no other turned on Hue lights nearby.</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">Returns:</th><td class="field-body">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that completes when a bulb has been successfully
reset, or when the reset attempt has failed.</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><tt class="xref py py-obj docutils literal"><span class="pre">BulbNotResetException</span></tt> if no bulb was reset.</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="playhouse.LightGrid">
<em class="property">class </em><tt class="descclassname">playhouse.</tt><tt class="descname">LightGrid</tt><a class="reference internal" href="_modules/playhouse.html#LightGrid"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.LightGrid" title="Permalink to this definition">¶</a></dt>
<dd><p>Keeps track of several bridges, abstracting access to individual lights.</p>
<dl class="method">
<dt id="playhouse.LightGrid.__init__">
<tt class="descname">__init__</tt><big>(</big><em>usernames=None</em>, <em>grid=None</em>, <em>buffered=False</em>, <em>defaults=None</em>, <em>assert_reachable=True</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#LightGrid.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.LightGrid.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Initializes the <a class="reference internal" href="#playhouse.LightGrid" title="playhouse.LightGrid"><tt class="xref py py-obj docutils literal"><span class="pre">LightGrid</span></tt></a>.</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>usernames</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><em>dict</em></a>) – Dictionary of MAC address -> username pairs. When a bridge is
added without specifying a username, and the bridge’s MAC address
is present in the <tt class="docutils literal"><span class="pre">usernames</span></tt> dictionary, the username of the
bridge will automatically be set to the corresponding value
in the dictionary.</li>
<li><strong>grid</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.4)"><em>list</em></a>) – A list of lists of <tt class="docutils literal"><span class="pre">(mac_address,</span> <span class="pre">light_id)</span></tt> tuples, specifying
a light belonging to a bridge with the given mac address.
Maps <tt class="docutils literal"><span class="pre">(x,</span> <span class="pre">y)</span></tt> coordinates to the light specified at <tt class="docutils literal"><span class="pre">grid[y][x]</span></tt>.</li>
<li><strong>buffered</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#bool" title="(in Python v3.4)"><em>bool</em></a>) – If <a class="reference external" href="http://docs.python.org/3/library/constants.html#True" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt></a>, calls to <a class="reference internal" href="#playhouse.LightGrid.set_state" title="playhouse.LightGrid.set_state"><tt class="xref py py-obj docutils literal"><span class="pre">set_state</span></tt></a> will not prompt an immediate
request to the bridge in question; to send the buffered state
changes, call <a class="reference internal" href="#playhouse.LightGrid.commit" title="playhouse.LightGrid.commit"><tt class="xref py py-obj docutils literal"><span class="pre">commit</span></tt></a>.</li>
<li><strong>defaults</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><em>dict</em></a>) – Additional instructions to include in each state change
request to a bridge.</li>
<li><strong>assert_reachable</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#bool" title="(in Python v3.4)"><em>bool</em></a>) – If <a class="reference external" href="http://docs.python.org/3/library/constants.html#True" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt></a>, the grid will occasionally check that all
bridges are reachable; any unreachable bridge will be removed.
Setting this parameter to <a class="reference external" href="http://docs.python.org/3/library/constants.html#True" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt></a> is equivalent to manually
calling the <a class="reference internal" href="#playhouse.LightGrid.assert_reachable" title="playhouse.LightGrid.assert_reachable"><tt class="xref py py-obj docutils literal"><span class="pre">assert_reachable</span></tt></a> method.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.LightGrid.add_bridge">
<tt class="descname">add_bridge</tt><big>(</big><em>ip_address_or_bridge</em>, <em>username=None</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#LightGrid.add_bridge"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.LightGrid.add_bridge" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a new bridge to this light 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 simple">
<li><strong>ip_address_or_bridge</strong> – Can be either a <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> object, or an IP address to a bridge,
in which case a new <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> object will be created from
the IP address.</li>
<li><strong>username</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.4)"><em>str</em></a>) – User name for this bridge. User names are required
to perform most bridge commands. Ignored if <tt class="docutils literal"><span class="pre">ip_address_or_bridge</span></tt>
is a <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> instance.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to the <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> instance added to
the <a class="reference internal" href="#playhouse.LightGrid" title="playhouse.LightGrid"><tt class="xref py py-obj docutils literal"><span class="pre">LightGrid</span></tt></a> when complete.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a></p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><tt class="xref py py-obj docutils literal"><span class="pre">NoBridgeFoundException</span></tt> if no bridge was found at the given IP address.</p>
<p class="last"><tt class="xref py py-obj docutils literal"><span class="pre">BridgeAlreadyAddedException</span></tt> if the <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> is already present
in the <a class="reference internal" href="#playhouse.LightGrid" title="playhouse.LightGrid"><tt class="xref py py-obj docutils literal"><span class="pre">LightGrid</span></tt></a>.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.LightGrid.has_bridge">
<tt class="descname">has_bridge</tt><big>(</big><em>mac_or_bridge</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#LightGrid.has_bridge"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.LightGrid.has_bridge" title="Permalink to this definition">¶</a></dt>
<dd><p>Check whether this <a class="reference internal" href="#playhouse.LightGrid" title="playhouse.LightGrid"><tt class="xref py py-obj docutils literal"><span class="pre">LightGrid</span></tt></a> has a bridge with the given MAC address
stored in its configuration.</p>
<p>If a <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> instance is given, compares <a class="reference internal" href="#playhouse.Bridge.serial_number" title="playhouse.Bridge.serial_number"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge.serial_number</span></tt></a> of
the provided instance to the known bridges.</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"><strong>mac_or_bridge</strong> – Either a MAC address or a <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> object.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference external" href="http://docs.python.org/3/library/constants.html#True" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt></a> if a <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> instance with the given MAC address is present
in the <a class="reference internal" href="#playhouse.LightGrid" title="playhouse.LightGrid"><tt class="xref py py-obj docutils literal"><span class="pre">LightGrid</span></tt></a>; <a class="reference external" href="http://docs.python.org/3/library/constants.html#False" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">False</span></tt></a> otherwise.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.LightGrid.set_usernames">
<tt class="descname">set_usernames</tt><big>(</big><em>usernames</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#LightGrid.set_usernames"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.LightGrid.set_usernames" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the username map for this light 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"><strong>usernames</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><em>dict</em></a>) – Dictionary of MAC address -> username pairs. See the <tt class="docutils literal"><span class="pre">usernames</span></tt>
parameter of <a class="reference internal" href="#playhouse.LightGrid.__init__" title="playhouse.LightGrid.__init__"><tt class="xref py py-obj docutils literal"><span class="pre">__init__</span></tt></a>.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.LightGrid.set_grid">
<tt class="descname">set_grid</tt><big>(</big><em>grid</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#LightGrid.set_grid"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.LightGrid.set_grid" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the grid that maps coordinates to <tt class="docutils literal"><span class="pre">(mac_address,</span> <span class="pre">light_id)</span></tt> pairs.</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"><strong>grid</strong> (<a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.4)"><em>list</em></a>) – A list of lists of <tt class="docutils literal"><span class="pre">(mac_address,</span> <span class="pre">light_id)</span></tt> tuples. See the <tt class="docutils literal"><span class="pre">grid</span></tt>
parameter of <a class="reference internal" href="#playhouse.LightGrid.__init__" title="playhouse.LightGrid.__init__"><tt class="xref py py-obj docutils literal"><span class="pre">__init__</span></tt></a>.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.LightGrid.set_state">
<tt class="descname">set_state</tt><big>(</big><em>x</em>, <em>y</em>, <em>**args</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#LightGrid.set_state"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.LightGrid.set_state" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the state for the light at the given coordinate.</p>
<p>If this grid is buffered, the state will not be sent to the lamp immediately; call
<a class="reference internal" href="#playhouse.LightGrid.commit" title="playhouse.LightGrid.commit"><tt class="xref py py-obj docutils literal"><span class="pre">commit</span></tt></a> to send the buffered state changes. See <a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-exc docutils literal"><span class="pre">HueAPIException</span></tt></a>.</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 simple">
<li><strong>x</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><em>int</em></a>) – X coordinate.</li>
<li><strong>y</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><em>int</em></a>) – Y coordinate.</li>
<li><strong>args</strong> – State argument, see the Philips Hue documentation.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that completes when <a class="reference internal" href="#playhouse.LightGrid.set_state" title="playhouse.LightGrid.set_state"><tt class="xref py py-obj docutils literal"><span class="pre">set_state</span></tt></a> has finished.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the grid is unbuffered and
the HTTP request failed.</p>
<p class="last"><a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the grid is unbuffered and the Hue API returned an error.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.LightGrid.set_all">
<tt class="descname">set_all</tt><big>(</big><em>**args</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#LightGrid.set_all"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.LightGrid.set_all" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the state of every light known to every bridge added to this <a class="reference internal" href="#playhouse.LightGrid" title="playhouse.LightGrid"><tt class="xref py py-obj docutils literal"><span class="pre">LightGrid</span></tt></a>.</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"><strong>args</strong> – State argument, see the Philips Hue documentation.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.LightGrid.commit">
<tt class="descname">commit</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/playhouse.html#LightGrid.commit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.LightGrid.commit" title="Permalink to this definition">¶</a></dt>
<dd><p>Commit buffered state changes to the lamps.</p>
<p>This method is automatically called whenever <a class="reference internal" href="#playhouse.LightGrid.set_state" title="playhouse.LightGrid.set_state"><tt class="xref py py-obj docutils literal"><span class="pre">set_state</span></tt></a> is called if the <tt class="docutils literal"><span class="pre">buffered</span></tt>
parameter of <a class="reference internal" href="#playhouse.LightGrid.__init__" title="playhouse.LightGrid.__init__"><tt class="xref py py-obj docutils literal"><span class="pre">__init__</span></tt></a> was set to <a class="reference external" href="http://docs.python.org/3/library/constants.html#False" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">False</span></tt></a>.</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">Returns:</th><td class="field-body">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to a dictionary consisting of
<tt class="docutils literal"><span class="pre">(x,</span> <span class="pre">y)</span></tt> coordinate -> exception object key/value pairs, where a given
exception object is associated with the operation of changing the state
of the light at the corresponding coordinate.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">dict</span></tt></a></td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><a class="reference external" href="http://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPError" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.httpclient.HTTPError</span></tt></a> if the HTTP request failed.
<a class="reference internal" href="#playhouse.HueAPIException" title="playhouse.HueAPIException"><tt class="xref py py-obj docutils literal"><span class="pre">HueAPIException</span></tt></a> if the Hue API returned an error.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="playhouse.LightGrid.assert_reachable">
<tt class="descname">assert_reachable</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/playhouse.html#LightGrid.assert_reachable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.LightGrid.assert_reachable" title="Permalink to this definition">¶</a></dt>
<dd><p>Coroutine that runs indefinitely, periodically ensuring that all bridges are reachable.</p>
<p>If a bridge cannot be reached three times in a row, it is removed from the <a class="reference internal" href="#playhouse.LightGrid" title="playhouse.LightGrid"><tt class="xref py py-obj docutils literal"><span class="pre">LightGrid</span></tt></a>.
Upon removing a bridge, <a class="reference internal" href="#playhouse.discover" title="playhouse.discover"><tt class="xref py py-obj docutils literal"><span class="pre">discover</span></tt></a> will be run once as a last-ditch effort to find
the lost bridge.</p>
<p>This method is automatically called if the <tt class="docutils literal"><span class="pre">assert_reachable</span></tt> parameter of <a class="reference internal" href="#playhouse.LightGrid.__init__" title="playhouse.LightGrid.__init__"><tt class="xref py py-obj docutils literal"><span class="pre">__init__</span></tt></a>
was set to <a class="reference external" href="http://docs.python.org/3/library/constants.html#True" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt></a>.</p>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="playhouse.discover">
<tt class="descclassname">playhouse.</tt><tt class="descname">discover</tt><big>(</big><em>attempts=2</em>, <em>timeout=2</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#discover"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.discover" title="Permalink to this definition">¶</a></dt>
<dd><p>Search for bridges on the local network.</p>
<p>Uses UPnP discovery to query the network for bridges. Additionally a request is sent to
<a class="reference external" href="http://www.meethue.com/api/nupnp">Philips’ NUPnP API</a>, which lists all bridges with the
same external IP address as the client issuing the 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 simple">
<li><strong>attempts</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><em>int</em></a>) – Number of times to run the UPnP discovery.</li>
<li><strong>timeout</strong> (<a class="reference external" href="http://docs.python.org/3/library/functions.html#int" title="(in Python v3.4)"><em>int</em></a>) – Time in seconds to wait for a new response during a UPnP discovery
attempt before giving up.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A <a class="reference external" href="http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future" title="(in Tornado v3.2.1)"><tt class="xref py py-obj docutils literal"><span class="pre">tornado.concurrent.Future</span></tt></a> that resolves to a list of <a class="reference internal" href="#playhouse.Bridge" title="playhouse.Bridge"><tt class="xref py py-obj docutils literal"><span class="pre">Bridge</span></tt></a> instances
when complete.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="http://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.4)"><tt class="xref py py-obj docutils literal"><span class="pre">list</span></tt></a></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="exception-classes">
<h2>Exception classes<a class="headerlink" href="#exception-classes" title="Permalink to this headline">¶</a></h2>
<div class="section" id="hue-api-errors">
<h3>Hue API errors<a class="headerlink" href="#hue-api-errors" title="Permalink to this headline">¶</a></h3>
<dl class="exception">
<dt id="playhouse.HueAPIException">
<em class="property">exception </em><tt class="descclassname">playhouse.</tt><tt class="descname">HueAPIException</tt><big>(</big><em>error</em>, <em>bridge</em><big>)</big><a class="reference internal" href="_modules/playhouse.html#HueAPIException"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#playhouse.HueAPIException" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</div>
<div class="section" id="other-errors">
<h3>Other errors<a class="headerlink" href="#other-errors" title="Permalink to this headline">¶</a></h3>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#"><tt class="docutils literal"><span class="pre">playhouse</span></tt> — Python library for communicating with Philips Hue bridges</a><ul>
<li><a class="reference internal" href="#bridge-management">Bridge management</a></li>
<li><a class="reference internal" href="#exception-classes">Exception classes</a><ul>
<li><a class="reference internal" href="#hue-api-errors">Hue API errors</a></li>
<li><a class="reference internal" href="#other-errors">Other errors</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="backend.html"
title="previous chapter">Light server</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="lightserver.html"
title="next chapter"><tt class="docutils literal"><span class="pre">lightserver</span></tt> — Server exposing an HTTP API for controlling several Philips Hue bridges</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/playhouse.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>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="lightserver.html" title="lightserver — Server exposing an HTTP API for controlling several Philips Hue bridges"
>next</a> |</li>
<li class="right" >
<a href="backend.html" title="Light server"
>previous</a> |</li>
<li><a href="index.html">Playhouse 0.1 documentation</a> »</li>
<li><a href="backend.html" >Light server</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2014, John Eriksson, Arvid Fahlström Myrman, Jonas Höglund, Hannes Leskelä, Christian Lidström, Mattias Palo, Markus Videll, Tomas Wickman, Emil Öhman.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
</body>
</html>