leopck / Yee-Light-Blue

Writing library for yee light blue using python for raspberry pi
32 stars 7 forks source link

Yee-Light-Blue and Yee-Light-Blue-2 (Beta)

Yee Light Blue 2 is located inside the yeelightblue2 branch. Please checkout to yeelightblue2 or change inside the drop down list above to yeelightblue2. Be warn the code is still in beta development and still requires testing.

Writing library for yee light blue using python for raspberry pi

Running test.py requires root

===============

Some guidelines into using this library

Install all the pre-requisite libraries and third-party tools

Credits to Ramin Sangesari in hackster.io for this

1. Get the required libraries

sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev

2. Download Bluez

sudo mkdir bluez
cd bluez
sudo wget www.kernel.org/pub/linux/bluetooth/bluez-5.31.tar.xz

3. Unzip and Compile Bluez

sudo unxz bluez-5.31.tar.xz
sudo tar xvf bluez-5.31.tar
cd bluez-5.31
sudo ./configure --disable-systemd
sudo make
sudo make install

4. Python Libraries

pip install pexpect

OR:

easy_install pexpect

If these doesn't work for you, it is most likely that you're missing pip and easy_install. You can either install them or you can manually install pexpect.

Manual Installation of pexpect

Go to https://pypi.python.org/pypi/pexpect/ and download the latest version.

For Linux System Only (Since I'm talking about Raspberry Pi here)

tar xzf pexpect-x.x.tar.gz
cd pexpect-x.x
sudo python ./setup.py install

===============

If you're interested in contributing into this library

===

Some API references guide

I'll just show the important ones with examples so that you can try this on your own and play with your RPi and Yee Light Blue.

Using test.py, you can try varies ways to control your Yee Light Blue.

connect: connects your RPi with the Yee Light Blue
Example:

x = yeelightblue.YeeLightBlue("00:xx:xx:xx:xx:xx", "hci0")

disconnect: disconnects your RPi with the Yee Light Blue
Example:

x.disconnect()

turnOn: Switches Yee Light Blue on
Example:

x.turnOn()

turnOff: Switches Yee Light Blue off
Example:

x.turnOff()

control: Controls the Yee Light Blue RGB and Brightness.
Format:

x.control(red, green, blue, brightness)

Example:

x.control('255','0','0','100') #This will output a very bright red color

========

TODO