forked from briandorey/tp-link-LB130-Smart-Wi-Fi-Bulb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.py
55 lines (43 loc) · 1.08 KB
/
demo.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Demo for the TP-Link A19-LB130 RBGW WiFi bulb
'''
import time
from tplight import LB130
def main():
'''
Main program function
'''
# create an instance of the light with its IP address
light = LB130("10.0.0.130")
# fetch the details for the light
print("Device ID: " + light.device_id)
print("Alias: " + light.alias)
print("Wattage: " + str(light.wattage))
# set the transition period for any changes to 1 seconds
light.transition_period = 0
# set the brightness to 50%
light.brightness = 50
time.sleep(2)
# set the saturation to 100%
light.saturation = 90
time.sleep(2)
# cycle through the colours
light.hue = 0
time.sleep(1)
light.hue = 60
time.sleep(1)
light.hue = 120
time.sleep(1)
light.hue = 180
time.sleep(1)
light.hue = 240
time.sleep(1)
light.hue = 300
time.sleep(1)
# set the colour to warm white and the brightness to 0
light.temperature = 3800
light.brightness = 0
if __name__ == "__main__":
main()