Setup for Mi-Light based on PaperUI

Knowing the basic concepts and tools of openHAB2 from previous blog contributions we are ready now for first setup of real home automatisation project. I have some Mi-Light bulbs in my house, therefore I want to start with these things. You can get the same Chinese hardware under other names: IWYLight, EasyBulb, LEDme, AppLight etc. etc.

I assume that the process described here is likewise for setup of Hue lamps and similar devices.

Use Case

I adapted the first slide for demonstrating our target setup. Let’s start with one RGB lamp.

TermsOpenHAB2_slide04_Milight.PNG

We have two things:

  • RGB lamp
  • MiLight Wifi gateway (this is a bridge)

Fortunally, there is already a binding for Milight implemented by David Graeff , see openHAB2-Milight2 git. The description tells us that the binding provides some channels for DiscoMode too.

Similar to native Milight smartphone app, we want to have following items (control elements):

  • ColorPicker
  • Switch (on/off)
  • slider for brightness

We will use BasicUI for presentation which is indicated in right upper corner.

Prerequsites in openHAB2

At first I decided to clean up my repository. After playing with some demo projects it was wasted with lots of things and items.

In Karaf console (see previous blog contribution) I inserted

  • things clear
  • items clear
  • links clear

(I had to repeat these steps until all elements are cleared, obviously there are same dependencies). With related “list” commands you can verify if the repository is empty.)

Please check that the configuration file <openHAB2 path>/conf/services/addons.cfg   contains

package=standard  (i.e. comment demo line to ignore demo things??)

Next step for preparation is installing the Milight binding. In Extensions- Bindings menu select “Milight Binding version 2.0” to install.

PaperUI_Extension_Miligt

You can check the result in menu Configuration -> bindings:

PaperUI_bindings

By pressing the MORE button the supported things are shown:

Milight_Binding_properties

We are happy that our RGBLed bulb and the Bridge is listed.

Its assumed that your Milight is already integrated into your home network (e.g. for using it with native smartphone app). Else, you have to do it because the Milight Wifi element needs an IP address. Here is a (German) tutorial  In my case the local fix IP address for Milight is 192.168.178.23.

Making Milight things known to openHAB2

The most easy way for integration is the Discovery service. Supply power to Milight Wifi element, switch on your lamp and go to Inbox panel which is empty this moment

InboxEmpty

Click on SCAN button DiscoveryButton and become euphoric!

This is the updated Things view:

Milight_Result_Discovery.PNG

In the Configuration->Things panel we can see our Milight bridge and a lot of supported things.

Hint: There is a flag in <con>/services/runtime.cfg (“autolink”) where you can decide if the detected elements are moved automatically or if you want to have everything under your own control.

The Milight controller supports up to 4 RGB lamps (“Color groups”). Unfortunately the bridge does not know which bulbs are present and the bulbs do not have a bidirectional communication. Therefore all possible bulbs are presented here.

At first we need the bridge and Color group 1 only. The bridge properties are already discovered, just the location, e.g.  “My room” is missing.

Milight_Bridges_Properties.PNG

Now we can edit thing “Color group1”- but even her the bridge was automatically detected and linked. Wow! Its amazing!

Milight_ColorGroup1.PNG

After confirmation of a location we get a view of provided channels:

Milight_Channels.PNG

You can verify this in console with command “things list”. In the moment, the channels are not assigned to any item – you see an hollow white circle in the blue shapes.

Finally, you can go to the “Control panel” and already play with the color. There is an automatically generated control for our lamp and it works perfectly!

Milight_Controls2

 

In the next blog chapter we will expand this example and create our first sitemap.

 

Powerful tools: PaperUI and Karaf

In openHAB1 all topics are stored in configuration files. That’s still possible and (partly) necessary in openHAB2, but the target of the project team is to administrate things, items, links (channels) etc. by a GUI called PaperUI and storing the data in an internal database.

PaperUI is one of the provided options in the “Welcome menu” shown when launching openHAB2 GUI in your browser (preferred is Chrome) with address “http://localhost:8080&#8221;

WelcomePanel

Hint: At first we will use BasicUI and PaperUI only, later we will talk about HABmin which has to be added as addon.

PaperUI starts with a menu where you can configure your openHAB2 installation:

PaperUI_extensions

In the example above we see the bindings extension  panel. In addition there a menu points for configuration (things, items, services and bindings), preferences etc.

All things identified by the Discovery service are shown in the Inbox panel. The Control panel is a kind of presentation GUI for items. There is an excellent introduction for PaperUI in this Youtube video by Kai Kreuzer.

One of my biggests issues as newcomer in openHAB2 was to understand how the items and things amanaged by PaperUI (and Discovery service) correlate to the configuration files. It seems that PaperUI only creates topics in its internal database. Nothing is written into configuration files automatically. But the manually created configuration files are still processed. Furthermore, what about the channels and binding information if we still use openHAB1 bindings? What is the really content of openHAB2  repositories?

You can querry this information in two ways:

  • configuration menu in PaperUI and
  • Karaf console

PaperUI is the preferred way, but currently there are still some gaps because PaperUI is still in beta phase. The good message is that the functionality will be increased step by step. Therefore, let’s use the Karaf command console in parallel (you get this in your  command window where openHAB2 was started (start.sh or start.bat):

Karaf_start

Typing “help” provides more than 300 possible commands. Don’t worry! For our needs just a handful of them is sufficient for our smarthome project – but we have to know the right ones.

Let’s start with “help smarthome” (sometimes it works better to write the topic partly only):

Karaf_HelpSmarthome

This gives us a first impression about the powerful set of commands.  By the way, you can optionally omit the prefix “smarthome:”, just type “help things”:

Karaf_HelpThings

.. or “things list”, “items list” etc.

In this way you are enabled to manage your things by commands! See this example:

Karaf_Things

You can remove things or clear the repository completely. Similarly you can access and manage your items, links, things, inbox etc. Again, the abbreviated version “things list”, “items list” etc. is allowed. In my case it was useful to get the correct names of Channels.

Karaf_Links

There are a lot of other helpful commands provided. Please try “config”, service”, “system” and “feature” in your console. With “feature:list” you get all available features. You can even filter for a certain feature:

feature:list | grep milight

Finally, we should mention the log commands. The log file can give you more insight what happens (or don’t work) in your openHAB2 setup.

Karaf_HelpLog