Skip to content

Osram Lightify

bern77 edited this page Jul 31, 2017 · 4 revisions

Osram Lightify Integration - Updated for openHAB 2

Usually Osram Lightify bulbs work nicely when connected to a Hue bridge which allows using the corresponding binding. However, if for some reason somebody is as unfortunate as me, i.e. the mix of bulbs in the house is located in a way that prevents that the (apparently proprietary) range extension functionality between devices doesn't ensure the bulbs can be reached (directly or indirectly) by the bridge, this approach might be useful.

Osram has published an API which could be used to control the bulbs. However, as this is handled via an Osram server, both privacy as well as latency issues render this a rather useless solution.

Instead, I came across a Python implementation using the binary protocol of the Lightify Gateway, which works very fast. My solution is based on the following components / code:

Python Script


pip install lightify

Run a simple Python script (changing the IP address to that of the Lightify Gateway) from lightify import Lightify

lightify = Lightify("<IP ADDRESS>")
lights = lightify.lights()
print lights

You then get a list of indexes in a format 'XXXXXXXXXXXXXXXXXXXL' (X being a digit). You can use


to identify which index corresponds to which bulb.

from lightify import Lightify
import argparse

# Light index

# process command line parameters
parser = argparse.ArgumentParser()
parser.add_argument('--bridge', help='IP Address of Lightify bridge')
parser.add_argument('--device', help='ID of the Lightify device')
parser.add_argument('--onoff', help='indicates if device should be switched into ON or OFF state', type=int)
parser.add_argument('--brightness', help='level of brightness to be used', type=float)
parser.add_argument('--saturation', help='saturation to be used', type=float)
parser.add_argument('--red', help='level of red to be used', type=float)
parser.add_argument('--green', help='level of green to be used', type=float)
parser.add_argument('--blue', help='level of blue to be used', type=float)
parser.add_argument('--temperature', help='colour temperature to be used', type=int)
parser.add_argument('--time', help='time for transition', type=int)
args = parser.parse_args()

# connect to Lightify bridge
if args.bridge != None:
    lightify = Lightify(args.bridge)
    lights = lightify.lights()

    if args.device != None:

        # device selection
        l = None
        if args.device == 'Room1':
            l = Room1
        elif args.device == 'Room2':
            l = Room2
        if l != None:
            light = lightify.lights()[l]

            # define RGB
            red = None
            green = None
            blue = None
            if != None:
                red = int(round(
            if != None:
                green = int(round(
            if != None:
                blue = int(round(
            time = 0
            if args.time != None:
                time = args.time

            if args.onoff != None and args.onoff == 0:
                if red != None and green != None and blue != None:
                    light.set_rgb(red, green, blue, time)
                if args.brightness != None:
                    light.set_luminance(args.brightness, time)
                if args.temperature != None:
                    light.set_temperature(args.temperature, time)

I placed the script into /openhab/scripts.

openHAB Integration


Assuming there are the following item definition:

Switch Lightify1_OnOff
Color  Lightify1_Colour
Dimmer Lightify1_Dimmer


Assuming there is a rule doing something like this:

var DecimalType hue = new DecimalType(240)
var PercentType sat = new PercentType(100)
var PercentType bright = new PercentType(100)
var HSBType light = new HSBType(hue, sat, bright)
sendCommand(Lightify1_Colour, light)

In order to make the Lightify bulb behave like there was a binding I've added an additional Rules file:


import org.eclipse.xtext.xbase.lib.Procedures$Procedure1
import org.eclipse.xtext.xbase.lib.Procedures$Procedure3

val String LIGHTIFY_SCRIPT = "python /openhab/scripts/ --bridge <IP ADDRESS> "

val Procedures$Procedure3<SwitchItem, DimmerItem, String> dimLightifyDevice = [
    SwitchItem s,
    DimmerItem d,
    String device |

    var cmd = LIGHTIFY_SCRIPT + '--device ' + device
    if (s.state == OFF) {
        cmd = cmd + ' --onoff 0'
    } else {
        if (d.state != NULL) {
            var b = (d.state as DecimalType).doubleValue
            cmd = cmd + ' --onoff 1 --brightness ' + b
        } else {
            cmd = cmd + ' --onoff 1'

val Procedures$Procedure1<String> switchOffLightifyDevice = [
    String device |

        executeCommandLine(LIGHTIFY_SCRIPT + '--device ' + device + ' --onoff 0')

val Procedures$Procedure3<SwitchItem, ColorItem, String> updateLightifyDevice = [ 
    SwitchItem s,
    ColorItem c,
    String device |

        var cmd = LIGHTIFY_SCRIPT + '--device ' + device
        if (s.state == OFF) {
            cmd = cmd + ' --onoff 0'
        } else {
            if (c.state != NULL) {
                var light = c.state as HSBType
                var red = / 100 * 255
                var green = / 100 * 255
                var blue = / 100 * 255
                cmd = cmd + ' --onoff 1 --brightness ' + light.brightness + ' --red ' + red + ' --green ' + green + ' --blue ' + blue
            } else {
                cmd = cmd + ' --onoff 1'

Note: You have to set the IP Address for your Lightify Gateway accordingly. You can then easily add rules for the individual bulbs:

rule "Lightify Workaround Lightify1"
        Item Lightify1_OnOff changed or
        Item Lightify1_Colour changed
        updateLightifyDevice.apply(Lightify1_OnOff, Lightify1_Colour, 'Room1')

feature overview


Setup intro

Linux and OS X





User Interfaces



(link to openHAB forum)



Application Integration



A good source of inspiration and tips from users gathered over the years. Be aware that things may have changed since they were written and some examples might not work correctly.

Please update the wiki if you do come across any out of date information.

Binding configurations

Use case examples

Item definition examples

Sitemap definition examples

Collections of Rules on a single page

Single Rules


Syntax highlighting for external editors

Release Notes

Clone this wiki locally
You can’t perform that action at this time.