API to remotely control the bulbs of the manufacturer yeelight.
Warning: This API only works with the RGB mode. The API has been tested with the color bulb models only.
It must be installed on a pc or raspberry pi with PHP 7.0 or higher.
The composer install
command must be executed to install the dependencies.
It is necessary to expose the web folder in apache or nginx. Requests must be made to the api.php
file.
To begin its use it is recommended to edit the file config.inc.php (Inside the "includes" folder) and establish a unique secret token.
It is also possible to modify the default values and the connection timeout to the bulbs.
The API only supports the POST method and the parameters specified as form-data.
Parameters | Default Value | Min Value | Max Value | Description |
---|---|---|---|---|
secretToken |
Secret token set in the config.inc.php file. | |||
bulbs |
all |
List of id or names of the bulbs to perform the operation separated by , . |
||
action |
Action to perform. The possible values are: get , name , power , bright , rgb , default & cycle . |
|||
name |
yeelight * |
Name to set to the bulb. The name can't contain spaces or special characters. | ||
power |
on * |
Determine if you want to turn the light bulbs on or off. The possible values are: on & off . |
||
bright |
100 * |
1 |
100 |
Determine the level of brightness. |
rgb |
FFFFFF * |
000000 |
FFFFFF |
Determine the color of the bulbs. |
effect |
sudden * |
Support two values: sudden and smooth . If effect is sudden , then the color temperature will be changed directly to target value, under this case, the parameter effect_duration is ignored. If effect is smooth , then the color temperature will be changed to target value in a gradual fashion, under this case, the total time of gradual change is specified in parameter effect_duration . |
||
effect_duration |
30 * |
30 |
10000 |
Specifies the total time of the gradual changing. The unit is milliseconds. |
cycles |
5 * |
1 |
20 |
Number of changes to be made. |
cycles_duration |
1000 * |
100 |
10000 |
Duration between cycles. The unit is milliseconds. |
*The default values can be modified in the file config.inc.php
- Required parameters:
secretToken
&action
. - Optional parameters:
bulbs
- Response:
{
"success": true,
"data": [
{
"id": "0x0000000000000000",
"name": "yeelight",
"address": "192.168.1.X:55443",
"power": "off",
"rgb": "ff0000",
"bright": "100"
}
]
}
- Required parameters:
secretToken
&action
. - Optional parameters:
bulbs
&name
.
- Required parameters:
secretToken
&action
. - Optional parameters:
bulbs
,power
,effect
&effect_duration
.
- Required parameters:
secretToken
&action
. - Optional parameters:
bulbs
,bright
,effect
&effect_duration
.
- Required parameters:
secretToken
&action
. - Optional parameters:
bulbs
,rgb
,effect
&effect_duration
.
- Required parameters:
secretToken
&action
. - Optional parameters:
bulbs
- Required parameters:
secretToken
&action
. - Optional parameters:
bulbs
,bright
,rgb
,cycles
&cycles_duration
.
MIT License
Copyright (c) 2018 Francisco Gómez Pino
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.