This repository has been archived by the owner on Mar 8, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from angadsingh/master
Bug fixes and improvements
- Loading branch information
Showing
6 changed files
with
532 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
SCENES = { | ||
1:"Ocean", | ||
2:"Romance", | ||
3:"Sunset", | ||
4:"Party", | ||
5:"Fireplace", | ||
6:"Cozy", | ||
7:"Forest", | ||
8:"Pastel Colors", | ||
9:"Wake up", | ||
10:"Bedtime", | ||
11:"Warm White", | ||
12:"Daylight", | ||
13:"Cool white", | ||
14:"Night light", | ||
15:"Focus", | ||
16:"Relax", | ||
17:"True colors", | ||
18:"TV time", | ||
19:"Plantgrowth", | ||
20:"Spring", | ||
21:"Summer", | ||
22:"Fall", | ||
23:"Deepdive", | ||
24:"Jungle", | ||
25:"Mojito", | ||
26:"Club", | ||
27:"Christmas", | ||
28:"Halloween", | ||
29:"Candlelight", | ||
30:"Golden white", | ||
31:"Pulse", | ||
32:"Steampunk", | ||
1000:"Rhythm" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import asyncio | ||
import asyncio_dgram | ||
import time | ||
from .wizlight import wizlight, PilotBuilder | ||
import logging | ||
import sys | ||
|
||
# python3 -m wiz_light.test | ||
|
||
root = logging.getLogger() | ||
root.setLevel(logging.DEBUG) | ||
|
||
handler = logging.StreamHandler(sys.stdout) | ||
handler.setLevel(logging.DEBUG) | ||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | ||
handler.setFormatter(formatter) | ||
root.addHandler(handler) | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
async def testbulb(bulb): | ||
wait_secs=10 | ||
|
||
state = await bulb.updateState() | ||
|
||
if state.get_state(): # check if on | ||
await asyncio.wait_for(bulb.turn_off(), wait_secs) | ||
await asyncio.sleep(0.5) | ||
await asyncio.wait_for(bulb.lightSwitch(), wait_secs) | ||
await asyncio.sleep(0.5) | ||
await asyncio.wait_for(bulb.turn_off(), wait_secs) | ||
await asyncio.sleep(0.5) | ||
await asyncio.wait_for(bulb.turn_on(PilotBuilder(brightness = 255)), wait_secs) | ||
await asyncio.sleep(0.5) | ||
await asyncio.wait_for(bulb.turn_on(PilotBuilder(brightness = 50)), wait_secs) | ||
await asyncio.sleep(0.5) | ||
await asyncio.wait_for(bulb.turn_on(PilotBuilder(rgb = (50, 100, 200))), wait_secs) | ||
await asyncio.sleep(0.5) | ||
await asyncio.wait_for(bulb.turn_on(PilotBuilder(colortemp = 4000)), wait_secs) | ||
await asyncio.sleep(0.5) | ||
await asyncio.wait_for(bulb.turn_on(PilotBuilder(colortemp = 6500)), wait_secs) | ||
await asyncio.sleep(0.5) | ||
await asyncio.wait_for(bulb.turn_on(PilotBuilder(scene = 14)), wait_secs) | ||
await asyncio.sleep(0.5) | ||
await asyncio.wait_for(bulb.turn_on(PilotBuilder(scene = 24)), wait_secs) | ||
|
||
state = await bulb.updateState() | ||
print(state.get_state()) | ||
print(state.get_scene()) | ||
print(state.get_scene()) | ||
print(state.get_warm_white()) | ||
print(state.get_speed()) | ||
print(state.get_cold_white()) | ||
print(state.get_rgb()) | ||
print(state.get_brightness()) | ||
print(state.get_colortemp()) | ||
|
||
|
||
async def run_bulb_automation(): | ||
loop = asyncio.get_event_loop() | ||
bulb1 = wizlight('192.168.1.58') | ||
bulb2 = wizlight('192.168.1.7') | ||
# await asyncio.gather(testbulb(bulb1), testbulb(bulb2), loop = loop) | ||
state = await bulb1.updateState() | ||
await bulb1.turn_on(PilotBuilder(scene = 14)) | ||
state = await bulb1.updateState() | ||
await asyncio.sleep(0.5) | ||
await bulb1.turn_on(PilotBuilder()) #rhythm | ||
state = await bulb1.updateState() | ||
|
||
if __name__ == '__main__': | ||
asyncio.run(run_bulb_automation()) |
Oops, something went wrong.