Debian Codegraph @

examples/aiozones.py

raw symbols SCIP
1 import asyncio
2 import logging
3 import pprint
4
5 from flux_led.aio import AIOWifiLedBulb
6 from flux_led.const import MultiColorEffects
7
8 logging.basicConfig(level=logging.DEBUG)
9
10
11 async def go():
12 bulb = AIOWifiLedBulb("192.168.106.118")
13
14 def _async_updated():
15 pprint.pprint(["State Changed!", bulb.raw_state])
16
17 await bulb.async_setup(_async_updated)
18 while True:
19 pprint.pprint("Setting to red/orange/yellow/green/blue/indigo/violet - static")
20 await bulb.async_set_zones(
21 [
22 (0xFF, 0x00, 0x00), # red
23 (0xFF, 0xA5, 0x00), # orange
24 (0xFF, 0xFF, 0x00), # yellow
25 (0x00, 0xFF, 0x00), # green
26 (0x00, 0x00, 0xFF), # blue
27 (0x4B, 0x00, 0x82), # indigo
28 (0xEE, 0x82, 0xEE), # violet
29 ],
30 100,
31 MultiColorEffects.STATIC,
32 )
33 await asyncio.sleep(5)
34
35 pprint.pprint("Setting to white/green - static")
36 await bulb.async_set_zones(
37 [(255, 255, 255), (0, 255, 0)], 100, MultiColorEffects.STATIC
38 )
39 await asyncio.sleep(5)
40
41 pprint.pprint("Setting to red/blue - static")
42 await bulb.async_set_zones(
43 [(255, 0, 0), (0, 0, 255)], 100, MultiColorEffects.STATIC
44 )
45 await asyncio.sleep(5)
46
47 pprint.pprint("Setting to white/blue - running water")
48 await bulb.async_set_zones(
49 [(255, 255, 255), (0, 0, 255)], 100, MultiColorEffects.RUNNING_WATER
50 )
51 await asyncio.sleep(5)
52
53 pprint.pprint("Setting to white/blue - breathing")
54 await bulb.async_set_zones(
55 [(255, 255, 255), (0, 0, 255)], 100, MultiColorEffects.BREATHING
56 )
57 await asyncio.sleep(5)
58
59 pprint.pprint("Setting to white/green - jump")
60 await bulb.async_set_zones(
61 [(255, 255, 255), (0, 255, 0)], 100, MultiColorEffects.JUMP
62 )
63 await asyncio.sleep(5)
64
65 pprint.pprint("Setting to red/blue - strobe")
66 await bulb.async_set_zones(
67 [(255, 0, 0), (0, 0, 255)], 100, MultiColorEffects.STROBE
68 )
69 await asyncio.sleep(5)
70
71 pprint.pprint(
72 "Setting to red/orange/yellow/green/blue/indigo/violet - running water"
73 )
74 await bulb.async_set_zones(
75 [
76 (0xFF, 0x00, 0x00), # red
77 (0xFF, 0xA5, 0x00), # orange
78 (0xFF, 0xFF, 0x00), # yellow
79 (0x00, 0xFF, 0x00), # green
80 (0x00, 0x00, 0xFF), # blue
81 (0x4B, 0x00, 0x82), # indigo
82 (0xEE, 0x82, 0xEE), # violet
83 ],
84 100,
85 MultiColorEffects.RUNNING_WATER,
86 )
87 await asyncio.sleep(5)
88
89
90 asyncio.run(go())