diff --git a/python webcam.py b/python webcam.py new file mode 100644 index 0000000..b2f2fe7 --- /dev/null +++ b/python webcam.py @@ -0,0 +1,16 @@ +import cv2 + +# id of the video capturing device to open. To open default camera using default backend just pass 0. +capture = cv2.VideoCapture(0) + +while True: + _, frame = capture.read() + # We give the Window a name of "Capture from Webcam", and we also give it the frame which is an numpy object. + cv2.imshow("Capture from Webcam", frame) + # We know that the ASCII code for the Escape key is 27. + if cv2.waitKey(1) == 27: + break + +# Release the capture and destroy all OpenCV Windows. +capture.release() +cv2.destroyAllWindows() diff --git a/yeelight1.py b/yeelight1.py new file mode 100644 index 0000000..c4f9a37 --- /dev/null +++ b/yeelight1.py @@ -0,0 +1,38 @@ +# Make sure you install yeelight +# pip3 install yeelight + +# Documentation here: https://yeelight.readthedocs.io/en/latest/ + +import time +from yeelight import Bulb +bulb = Bulb("192.168.0.105") + +bulb.turn_on() +time.sleep(1) +bulb.set_rgb(255,0,0) +time.sleep(1) +bulb.set_rgb(164,168,50) +time.sleep(1) +bulb.set_rgb(50,90,168) +time.sleep(1) +bulb.set_rgb(168,50,50) +time.sleep(1) +bulb.set_rgb(50,168,54) +time.sleep(1) +bulb.set_rgb(255,0,0) +time.sleep(1) + +rgb1 = 50 +rgb2 = 10 +rgb3 = 50 +for i in range(10): + bulb.set_rgb(rgb1,rgb2,rgb3) + time.sleep(1) + i = i + 1 + rgb1 = (i*10.5) + rgb2 = (i*5.5) + rgb3 = (i*9.5) + print(rgb1, rgb2, rgb3) + bulb.set_rgb(rgb1,rgb2,rgb3) + +bulb.set_rgb(255,0,0) diff --git a/yeelight2.py b/yeelight2.py new file mode 100644 index 0000000..879b9b6 --- /dev/null +++ b/yeelight2.py @@ -0,0 +1,48 @@ +# Make sure you install yeelight +# pip3 install yeelight + +# Documentation here: https://yeelight.readthedocs.io/en/latest/ + +import time +from yeelight import Bulb +bulb1 = Bulb("192.168.0.105") +bulb2 = Bulb("192.168.0.117") +bulb1.turn_on() +bulb2.turn_on() +time.sleep(1) + +bulb1.set_rgb(255,0,0) +bulb2.set_rgb(255,0,0) +time.sleep(1) + +bulb1.set_rgb(164,168,50) +time.sleep(1) + +bulb2.set_rgb(50,90,168) +time.sleep(1) + +bulb1.set_rgb(168,50,50) +time.sleep(1) + +bulb2.set_rgb(50,168,54) +time.sleep(1) + +bulb1.set_rgb(255,0,0) +time.sleep(1) + +rgb1 = 50 +rgb2 = 10 +rgb3 = 50 +for i in range(10): + bulb1.set_rgb(rgb1,rgb2,rgb3) + bulb2.set_rgb(rgb1-10,rgb2-10,rgb3-10) + time.sleep(1) + i = i + 1 + rgb1 = (i*10.5) + rgb2 = (i*5.5) + rgb3 = (i*9.5) + print(rgb1, rgb2, rgb3) + bulb1.set_rgb(rgb1,rgb2,rgb3) + +bulb1.set_rgb(50,64,168) +bulb2.set_rgb(50,64,168) diff --git a/yeelight_discover.py b/yeelight_discover.py new file mode 100644 index 0000000..71a16f1 --- /dev/null +++ b/yeelight_discover.py @@ -0,0 +1,19 @@ +# Make sure you install yeelight +# pip3 install yeelight + +# Documentation here: https://yeelight.readthedocs.io/en/latest/ + +from yeelight import discover_bulbs +discover_bulbs() + +from yeelight import Bulb +bulb = Bulb("192.168.0.105") + +bulb.turn_on() +bulb.get_properties() +bulb.set_brightness(50) +bulb.set_rgb(255, 0, 0) +bulb.set_rgb(1, 0, 0) + +bulb.set_color_temp(200) +bulb.set_color_temp(4700) diff --git a/yeelight_telnet b/yeelight_telnet new file mode 100644 index 0000000..4391c45 --- /dev/null +++ b/yeelight_telnet @@ -0,0 +1,4 @@ +telnet 192.168.0.105:55443 + +{"id":0,"method":"set_power","params":["on", "smooth", 200]} +{"id":0,"method":"set_power","params":["off", "smooth", 200]}