Home PageMilight ha bridge control

Milight ha bridge control

The ha bridge software emulates a Philips hue bridge. This means you can use the functionality built in to the amazon echo and its integration with the philips hue.
This is the location of the echo bridge software
https://github.com/bwssytems/ha-bridge/releases/download/v1.4.2/ha-bridge-1.4.2.jar
You can install the software onto the raspberry pi as follows.
Create a directory echobridge for example and install the software as follows.
pi@raspberrypi:~/echobridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v1.4.2/ha-bridge-1.4.2.jar
You need to make the directory read write so that you can save the database file later.
Turning on the software can be done when you know the IP of the raspberry.
pi@raspberrypi:~/echobridge $ java -jar ha-bridge-1.4.2.jar -upnp.config.address=192.168.0.22
Then you need to edit the configuration. This is done by going to 192.168.0.22:8080 with your browser.

Logitech Squeezebox

Logitech squeezebox

This device is a network music player which can be controlled in a variety of ways.
I already made some attempts to control it through the web here.
But what would becooler than to be able to control it through the amazon echo and have it fully voice controlled.
So how to make this happen. Well first step is to give the device a name eg a radio veronica or something.
Select Vera Device from the Map Type.
Http Verb is GET and Content Type is text/plain.
Then you can fill in the On, Off and Dim URL.
Some suggestions.
ON URL : http://192.168.0.107:9002/plugins/Favorites/index.html?action=play&index=4
Turns on the favourite station number four which happens to be radio veronica.
OFF URL: http://192.168.0.107:9002/status.html?p0=stop
Stops the squeezebox player
DIM URL : http://192.168.0.107:9002/status.html?p0=mixer&p1=volume&p2=${intensity.percent}
This sets the volume of the current radio station to x percent. I have this DIM command on every radio station that i have so that you can set the volume by using the device.
Alexa, Set radio veronica to 50 percent.
The ${intensity.percent} comes from the philips hue bridge.
Of course you need first to discover the new devices by saying Alexa, discover devices.
Once discovered you can say the following.
You can say the following things.
Alexa, Set radio veronica to 40 percent
Alexa, turn on radio veronica
Alexa, turn off radio veronica
To have the amazon echo change the station simply create another device with the same name and change the index number to match that station.
The IP of the squeezebox needs to be in the same network as the raspberry pi running tha ha bridge software.

Milight bulbs

For Limitless LED its the same procedure but here you need the UDP commands.
ON URL: udp://192.168.0.24:8899/0x450055
OFF URL: udp://192.168.0.24:8899/0x460055
The DIM command can not work using the standard Philips hue interface because the milight bulbs require multiple commands to be sent one after another.
You can read about this on the Milight PHP control page. Below you can see some of these commands.

set to white max brightness
$milight->rgbwAllOn();
$milight->rgbwAllSetToWhite();
$milight->rgbwAllBrightnessMax();

Dim to 50%
$milight->setRgbwActiveGroup(1);
$milight->rgbwBrightnessPercent(50);

Change colour to red
$milight->setRgbwActiveGroup(1);
$milight->rgbwSetColorHexString(‘FF1254’); // or #FF1254
$milight->rgbwBrightnessPercent(10);

Increase brightness to max
$milight->setRgbwActiveGroup(1);
$milight->rgbwBrightnessMax();

Nightmode
$milight->rgbwAllOn();
$milight->rgbwAllNightMode();

You can however use PHP to execute these two commands and direct the ha bridge to the PHP page.
So i set the ON URL to eg http://192.168.0.107/LimitlessLED/milightblue.php
The milightblue.php contains the code to turn the milight to blue. This is simply the code below.
<?php
require ‘Milight.php’;
$milight = new Milight(‘192.168.0.24’);
$milight->setRgbwActiveGroup(1);
$milight->rgbwSetColorHexString(‘0000FF’); // or #FF1254
?>
Create this file in the same network as the raspberry pi running the ha bridge software.

In the same way it is possible to set the brightness of the milight bulb.
http://192.168.0.107/LimitlessLED/test.php?brightness=${intensity.percent}
The relevant php file is.
<?php
//to keep it simple using require
require ‘Milight.php’;
$milight = new Milight(‘192.168.0.24’);
// The value of the variable name is found
echo “<h1>Hello from Milight” . “</h1>”;
$var1=$_GET[“brightness”];
echo nl2br (“Set milight brightness to “. $var1 . “%\n”);
$milight->setRgbwActiveGroup(1);
$milight->rgbwBrightnessPercent($var1);
?>

 
Finally i want to use the philips hue emulator so simulate a Philips Hue bridge and allow the milight to be controlled as a Philips Hue bulb with the Amazon echo. I use the following emulator to control my squeezebox network music player and this works exactly the way i would like to control the milight bulb. You are able to pass a parameter to the device using ${intensity.byte}, ${intensity.percent} or ${intensity.math}.
The commands to the Amazon echo are then.

To do this… Say this…
Discover “Alexa, discover my devices.”
Turn On “Alexa, turn on the kitchen light.”
Turn Off “Alexa, turn off the kitchen light.”
Brighten “Alexa, brighten the kitchen light.”
Dim “Alexa, dim the kitchen light.”
Dim “Alexa, Dim the lights to 40%.”
Set “Alexa, set the kitchen light to 50%.”
Set “Alexa, Set brightness to 60%.”