- Introduction
- Requirements
- How to install
- How does it work?
- Currently implemented method
- Example
- Testing the library
- Credits
It's a very simple PHP library to allows you to communicate with your Yeelight RGB lights.
This library is all based on the official documentation from Yeelight.
- PHP 7.4 or up (tested with PHP 8.0)
- PHP sockets extension
- PHP JSON extension
- Yeelight local network control enabled on your lights
- Require the library using Composer:
composer require sharkezz/yeephp
- Require the composer autoloader (if it is not done yet)
- Instantiate a new Yeelight object
- Use it!
Yeelight-PHP use PHP sockets to communicate with your lights, that make it fast and reliable!
It can as well be used in your 'from scratch' project or in the framework of your choice!
This list is temporary, expect more methods to come
- Set the color (RGB) of the light
- Set the light brightness
- Set the light name
- Set the light power (on of off)
- Get light infos (partially completed)
- Color Flow control
- Proper error handling
Imagine that the Yeelight has the IP 192.168.0.15 and is using the default port (55443), in order to change the light color, you can do this:
<?php
require_once './vendor/autoload.php';
use SharkEzz\Yeelight\YeePHP;
// Create a new instance of Yeelight-PHP
$yeelight = new YeePHP('192.168.0.15');
// Set the color of the light, notice that all the 'set' methods are fluent, it means that you can use them in chain !
$yeelight->setColor(0xFF0000)
->commit(); // The commit method has to be called at the end to send the commands to the light
<?php
require_once './vendor/autoload.php';
use SharkEzz\Yeelight\YeePHP;
$yeelight = new YeePHP('192.168.0.15');
$yeelight->setBrightness(50)
->commit();
<?php
require_once './vendor/autoload.php';
use SharkEzz\Yeelight\YeePHP;
$yeelight = new YeePHP('192.168.0.15');
$yeelight->setBrightness(50)
->setColor(0x00FF00)
->commit();
If you want to test this library, make sure you have a working Yeelight RGB light in your local network.
You juste have to set the $ip
variable in the LightTest.php
file in the tests
folder.
Then just run the PHPUnit executable: ./vendor/bin/phpunit
Official Yeelight documentation
Inspired by Yeelight-PHP from itskenny0