Home PageMilight php udp control

Milight PHP UDP control

If you have a milight bridge you can command the milight bulbs with UDP commands.
The more recent bridges have a web interface with which you can configure the device.
There is also a windows tool which does more or less the same.
The web configurator can be reached once you know the IP address. http://192.168.0.24/index_en.html
limitless bridge
You can test the UDP functionality with the freeware tool of which the link is below.
https://www.simplecomtools.com/ProductCart/pc/viewPrd.asp?idproduct=6&idcategory=5
The testtool needs to be configured by setting the port and IP address as below.

UDP test tool

The UDP commands are allways 3 bytes and for the milight bulb RGBWW which i have it responds as follows.

Hexidecimal (byte)

RGBW COLOR LED ALL OFF 0x41
RGBW COLOR LED ALL ON 0x42
DISCO SPEED SLOWER 0x43
DISCO SPEED FASTER 0x44
GROUP 1 ALL ON 0x45 (SYNC/PAIR RGB+W Bulb within 2 seconds of Wall Switch Power being turned ON)
GROUP 1 ALL OFF 0x46
GROUP 2 ALL ON 0x47 (SYNC/PAIR RGB+W Bulb within 2 seconds of Wall Switch Power being turned ON)
GROUP 2 ALL OFF 0x48
GROUP 3 ALL ON 0x49 (SYNC/PAIR RGB+W Bulb within 2 seconds of Wall Switch Power being turned ON)
GROUP 3 ALL OFF 0x4A
GROUP 4 ALL ON 0x4B (SYNC/PAIR RGB+W Bulb within 2 seconds of Wall Switch Power being turned ON)
GROUP 4 ALL OFF 0x4C
DISCO MODE 0x4D
SET COLOR TO WHITE (GROUP ALL) 0x42 100ms followed by: 0xC2
SET COLOR TO WHITE (GROUP 1) 0x45 100ms followed by: 0xC5
SET COLOR TO WHITE (GROUP 2) 0x47 100ms followed by: 0xC7
SET COLOR TO WHITE (GROUP 3) 0x49 100ms followed by: 0xC9
SET COLOR TO WHITE (GROUP 4) 0x4B 100ms followed by: 0xCB

LIMITLESSLED RGBW DIRECT BRIGHTNESS SETTING is by a 3 BYTE COMMAND: (First send the Group ON for the group you want to set the brightness for. You send the group ON command 100ms before sending the 4E 00 55)
Byte1: 0x4E Byte2: 0x00 to 0xFF (full brightness 0x3B) Byte3: Always 0x55

LIMITLESSLED RGBW COLOR SETTING is by a 3 BYTE COMMAND: (First send the Group ON for the group you want to set the colour for. You send the group ON command 100ms before sending the 40)
Byte1: 0x40 Byte2: 0x00 to 0xFF (255 colors) Color Matrix Chart [COMING SOON] Byte3: Always 0x55

colour ring

Night modes, not implemented for RGBW, but referenced here for completeness..
NIGHT MODE ALL 0x41 100ms followed by: 0xC1 (not implemented in limitlessled wifi bridge 3.0)
NIGHT SAVER MODE GROUP 1 0x46 100ms followed by: 0xC6 (not implemented in limitlessled wifi bridge 3.0)
NIGHT SAVER MODE GROUP 2 0x48 100ms followed by: 0xC8 (not implemented in limitlessled wifi bridge 3.0)
NIGHT SAVER MODE GROUP 3 0x4A 100ms followed by: 0xCA (not implemented in limitlessled wifi bridge 3.0)
NIGHT SAVER MODE GROUP 4 0x4C 100ms followed by: 0xCC (not implemented in limitlessled wifi bridge 3.0)

So those are the commands so now how to use them.
I used the PHP software developed by Yashar Rashedi which you can find here.
There is also a local link here. This also contains the code for operating the ha bridge.
I also wrote a small piece of PHP code which operates the different functionality which you can see below.
You can set the colour, brightness, nightmode etc using this interface and i have used this to control the milight bulbs using the ha bridge.

<?php
//to keep it simple using require
require ‘Milight.php’;
$milight = new Milight(‘192.168.0.24’);
echo nl2br (“set to white max brightness \n”);
flush();ob_flush();flush();ob_flush();
$milight->rgbwAllOn();
$milight->rgbwAllSetToWhite();
$milight->rgbwAllBrightnessMax();
sleep(4);
echo nl2br (“Dim to 50% \n”);
flush();ob_flush();flush();ob_flush();
$milight->setRgbwActiveGroup(1);
$milight->rgbwBrightnessPercent(20);
sleep(4);
echo nl2br (“Change colour to red \n”);
flush();ob_flush();flush();ob_flush();
$milight->setRgbwActiveGroup(1);
$milight->rgbwSetColorHexString(‘FF1254’); // or #FF1254
$milight->rgbwBrightnessPercent(10);
sleep(4);
echo nl2br (“Increase brightness to max \n”);
flush();ob_flush();flush();ob_flush();
$milight->setRgbwActiveGroup(1);
$milight->rgbwBrightnessMax();
sleep(4);
echo nl2br (“Nightmode \n”);
flush();ob_flush();flush();ob_flush();
$milight->rgbwAllOn();
#$milight->rgbwAllSetToWhite();
#$milight->rgbwAllBrightnessMax();
$milight->rgbwAllNightMode();
sleep(4);
for ($x = 0; $x <= 100; $x++) {
$milight->rgbwAllSetToWhite();
$milight->rgbwBrightnessPercent(rand(60,100));
usleep(200);
}
?>

With the above you can make amazon echo commands such as.

Alexa, turn on milight
Alexa, turn on milight blue
Alexa, set brightness to 50 percent