Monday, 13 March 2017

HOME AUTOMATION: MiLight/LimitlessLED/Easybulb OpenHAB Configuration

I've been thinking about wireless lighting control for a while now and tested out the space with the MiLight wireless controlled light bulbs.

My initial use case was focused around bulb dimming and while I realise I could have achieved this with a simple dimmer switch costing around 20 bucks from Bunnings, the cost of hiring an Electrician to come to wire a single switch would easily run be over $100. I know some people take to doing this themselves but you need to remember this is illegal in Australia.


The Research

The majority of my house is fitted with modern downlights that use the GU10 socket. This is a pretty common fitting type so the number of options is quite large. Here are a few of the options I considered:
  • MiLight/LimitlessLED/Easybulb - 15USD and around 10USD for a bridge
  • Phillips Hue - 4 wireless bulbs and a bridge at $399 or $89 per bulb
  • LiFX GU10 WiFi bulbs - 4 wireless downlights at $120 or $40 per bulb

As my main use case was brightness control I went for the MiLight bulbs that I bought from the LimitlessLED website.

While the cheapest, the MiLight bulbs have downside of no publishing their state when the lights are turned on.

This may not sound like a big deal, but after having used the bulbs in my home automation setup I can say that this limitation is quite annoying as there is no easy way to manage the state of the bulbs in your home automation setup. Unless you can see the lights left on you don't really know what state they are in, so the only useful feature when you are away is the blanket "All Off". It's not the worst but it's definitely not ideal.

The MiLight bulbs are not Wi-Fi, they use the a 2.4GHz wireless protocol that requires a Wi-Fi bridge to connect it to your home network. There are a few limitations with these Wi-Fi bridges and some folks have developed their own bridges that overcome these limitations, but I'm going to be sticking with the standard as the OpenHAB MiLight binding has been designed to work with this device.


Setting Up Your MiLight Bridge

Follow the MiLight instructions to set up your bridge to control the bulb groups in your house using the Android or iOS apps. Here are a few tips:
  • If you are using the Android app I've noticed it works much better on an old phone in airplane mode. The app experience on Android Nougat is horrible
  • Make sure you assign a static IP for your Wi-Fi bridge on your router
  • Once you have taught the bridge your light groups make a note so your don't forget which group was associated with each channel of the bridge
  • Each bridge can only control 4 groups of WW/CW and 4 groups of RGB/W bulbs
  • Each bridge has an "All Off" channel. Think about how many bridges you might want to make this function useful. In my setup I have 1 bridge per floor.


MiLight Wi-Fi Bridge with OpenHAB

I follow these steps to get my MiLight bulbs set up with my OpenHAB installation:
  • Navigate to the PaperUI page of your OpenHAB installation to configure you devices
PaperUI Configuration

  • Install the MiLight add-on 
MiLight Add-on

  • Navigate to the inbox and search for new devices
  • At this point you will see a number of devices listed under the MiLight services in the inbox 
    • 4 channels of WW/CW
    • 4 channels of RGB/W
    • 1 channel of WW/CW all off
    • 1 channel of RGB/W all off 
MiLight Bridge Channel
Now we need to add the devices be previously taught the Wi-Fi bridge in the setup step. This is done by clicking the check icon on the device we want to add, then follow the steps to add the device.

I followed the advice in the OpenHAB instructions and set the system to enable "Item Linking" to make the addition of Things easier.
Item Linking configuration


Once you have added the devices you plan to use the next thing to do is check they are working as expected via the configuration panel.

Testing Things in configuration panel


If your device's aren't working at this point you'll need to go back to the bridge setup step and make sure everything is working there. 


OpenHAB .items Configuration

With the devices now added as Things in your OpenHAB installation we need to add the bulbs as a .items file to get them running with our user interface.
Navigate to the items folder of the OpenHAB installation folder and create a new .items file:
 cd /etc/openhab2/items/  
 sudo nano lights.items  

Here we will add the devices we wish to use with our user interface. The MiLight binding gives some examples of how to configure the devices, but for quick reference this is how it's done.

  • Get the unique ID of the device you want to add from the Things banner of the Configuration panel. You need to click the Thing and view the available channels
Click the Thing you want to add to the .items file

Copy the channel you want to use

  • Add the ID to the item and give it a unique name. Here is an example:
 Switch Light_GF_Laundry_OnOff        {channel="milight:whiteLed:ACCF23508A5A:1:ledbrightness"}
 Switch Light_GF_Laundry_NightMode    {channel="milight:whiteLed:ACCF23508A5A:1:lednightmode"}
 Dimmer Light_GF_Laundry_Temperature  {channel="milight:whiteLed:ACCF23508A5A:1:ledtemperature"}
 Dimmer Light_GF_Laundry_Brightness   {channel="milight:whiteLed:ACCF23508A5A:1:ledbrightness"}

  • Repeat this process for all the devices you want to add, then move on to the sitemap
Note: the MiLight binding does not expose and on/off state for the bulbs, rather you need to define a switch for the brightness to control the on/off and a dimmer for the brightness adjustment both using the same channel



OpenHAB Sitemap Configuration

With the devices added to your items file now we can add them to your sitemap. This is the file that outlays the user interface for user interaction with the OpenHAB setup.

Navigate to the OpenHAB installation directory and then to the sitemap directory. If you are coming from a fresh installation you probably won't have anything in here other than a readme.txt file so you will also need to create a default.sitemap file.
 cd /etc/openhab2/sitemaps/  
 sudo nano default.sitemap  

We will start with a basic working sitemap to test the functions of the devices we just added.
 sitemap default label="Test Layout" {  
     Frame label="Laundry" {  
         Switch item=Light_GF_Laundry_OnOff label="On/Off"  
         Slider item=Light_GF_Laundry_Brightness label="Brightness"  
         Switch item=Light_GF_Laundry_NightMode label="Night Mode"  
     }  
 }  

And here is the output:

2 comments:

  1. Thank you! This did work for me when the official openhab2 instructions did not. And here is the problem - All detected well, and I think I could have manually set it up, but I started simple with just the on/off. I stumbled onto your comment:
    "Note: the MiLight binding does not expose and on/off state for the bulbs, rather you need to define a switch for the brightness to control the on/off and a dimmer for the brightness adjustment both using the same channel"

    which actually contradicts the OpenHAB2 instructions that imply that just this would turn the bulb on/off:
    Switch Light_GF_Laundry_OnOff {channel="milight:whiteLed:ACCF23508A5A:1"}

    Which is obviously not the case...

    Thanks so much!

    ReplyDelete
    Replies
    1. Glad you found this useful! I remember being tripped up by the switch connected to the brightness element, it could definitely be better explained in the openHAB docs. Maybe I should make that note a little more obvious.

      Delete