-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Osram Lightify
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:
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>")
lightify.update_all_light_status()
lights = lightify.lights()
print lights
You then get a list of indexes in a format 'XXXXXXXXXXXXXXXXXXXL' (X being a digit). You can use
lightify.lights()[XXXXXXXXXXXXXXXXXXXL].set_onoff(1)
to identify which index corresponds to which bulb.
from lightify import Lightify
import argparse
# Light index
Room1 = XXXXXXXXXXXXXXXXXXXL
Room2 = XXXXXXXXXXXXXXXXXXXL
#...
# 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)
lightify.update_all_light_status()
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 args.red != None:
red = int(round(args.red))
if args.green != None:
green = int(round(args.green))
if args.blue != None:
blue = int(round(args.blue))
time = 0
if args.time != None:
time = args.time
if args.onoff != None and args.onoff == 0:
light.set_onoff(0)
else:
light.set_onoff(1)
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.
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/mylightify.py --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'
}
}
executeCommandLine(cmd)
]
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 = light.red / 100 * 255
var green = light.green / 100 * 255
var blue = light.blue / 100 * 255
cmd = cmd + ' --onoff 1 --brightness ' + light.brightness + ' --red ' + red + ' --green ' + green + ' --blue ' + blue
} else {
cmd = cmd + ' --onoff 1'
}
}
executeCommandLine(cmd)
]
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"
when
Item Lightify1_OnOff changed or
Item Lightify1_Colour changed
then
updateLightifyDevice.apply(Lightify1_OnOff, Lightify1_Colour, 'Room1')
end
ℹ Please find all documentation for openHAB 2 under http://docs.openhab.org.
The wiki pages here contain (outdated) documentation for the older openHAB 1.x version. Please be aware that a lot of core details changed with openHAB 2.0 and this wiki as well as all tutorials found for openHAB 1.x might be misleading. Check http://docs.openhab.org for more details and consult the community forum for all remaining questions.
- Classic UI
- iOS Client
- Android Client
- Windows Phone Client
- GreenT UI
- CometVisu
- Kodi
- Chrome Extension
- Alfred Workflow
- Cosm Persistence
- db4o Persistence
- Amazon DynamoDB Persistence
- Exec Persistence
- Google Calendar Presence Simulator
- InfluxDB Persistence
- JDBC Persistence
- JPA Persistence
- Logging Persistence
- mapdb Persistence
- MongoDB Persistence
- MQTT Persistence
- my.openHAB Persistence
- MySQL Persistence
- rrd4j Persistence
- Sen.Se Persistence
- SiteWhere Persistence
- AKM868 Binding
- AlarmDecoder Binding
- Anel Binding
- Arduino SmartHome Souliss Binding
- Asterisk Binding
- Astro Binding
- Autelis Pool Control Binding
- BenQ Projector Binding
- Bluetooth Binding
- Bticino Binding
- CalDAV Binding
- Chamberlain MyQ Binding
- Comfo Air Binding
- Config Admin Binding
- CUL Transport
- CUL Intertechno Binding
- CUPS Binding
- DAIKIN Binding
- Davis Binding
- DD-WRT Binding
- Denon Binding
- digitalSTROM Binding
- DIY on XBee Binding
- DMX512 Binding
- DSC Alarm Binding
- DSMR Binding
- eBUS Binding
- Ecobee Binding
- EDS OWSever Binding
- eKey Binding
- Energenie Binding
- EnOcean Binding
- Enphase Energy Binding
- Epson Projector Binding
- Exec Binding
- Expire Binding
- Fatek PLC Binding
- Freebox Binding
- Freeswitch Binding
- Frontier Silicon Radio Binding
- Fritz AHA Binding
- Fritz!Box Binding
- FritzBox-TR064-Binding
- FS20 Binding
- Garadget Binding
- Global Caché IR Binding
- GPIO Binding
- HAI/Leviton OmniLink Binding
- HDAnywhere Binding
- Heatmiser Binding
- Homematic / Homegear Binding
- Horizon Mediabox Binding
- HTTP Binding
- IEC 62056-21 Binding
- IHC / ELKO Binding
- ImperiHome Binding
- Insteon Hub Binding
- Insteon PLM Binding
- IPX800 Binding
- IRtrans Binding
- jointSPACE-Binding
- KM200 Binding
- KNX Binding
- Koubachi Binding
- LCN Binding
- LightwaveRF Binding
- Leviton/HAI Omnilink Binding
- Lg TV Binding
- Logitech Harmony Hub
- MailControl Binding
- MAX!Cube-Binding
- MAX! CUL Binding
- MCP23017 I/O Expander Binding
- MCP3424 ADC Binding
- MiLight Binding
- MiOS Binding
- Mochad X10 Binding
- Modbus Binding
- MPD Binding
- MQTT Binding
- MQTTitude binding
- MystromEcoPower Binding
- Neohub Binding
- Nest Binding
- Netatmo Binding
- Network Health Binding
- Network UPS Tools Binding
- Nibe Heatpump Binding
- Nikobus Binding
- Novelan/Luxtronic Heatpump Binding
- NTP Binding
- One-Wire Binding
- Onkyo AV Receiver Binding
- Open Energy Monitor Binding
- OpenPaths presence detection binding
- OpenSprinkler Binding
- OSGi Configuration Admin Binding
- Panasonic TV Binding
- panStamp Binding
- Philips Hue Binding
- Picnet Binding
- Piface Binding
- PiXtend Binding
- pilight Binding
- Pioneer-AVR-Binding
- Plex Binding
- Plugwise Binding
- PLCBus Binding
- PowerDog Local API Binding
- Powermax alarm Binding
- Primare Binding
- Pulseaudio Binding
- Raspberry Pi RC Switch Binding
- RFXCOM Binding
- RWE Smarthome Binding
- Sager WeatherCaster Binding
- Samsung AC Binding
- Samsung TV Binding
- Serial Binding
- Sallegra Binding
- Satel Alarm Binding
- Siemens Logo! Binding
- SimpleBinary Binding
- Sinthesi Sapp Binding
- Smarthomatic Binding
- Snmp Binding
- Somfy URTSI II Binding
- Sonance Binding
- Sonos Binding
- Souliss Binding
- Squeezebox Binding
- Stiebel Eltron Heatpump
- Swegon ventilation Binding
- System Info Binding
- TA CMI Binding
- TCP/UDP Binding
- Tellstick Binding
- TinkerForge Binding
- Tivo Binding
- UCProjects.eu Relay Board Binding
- UPB Binding
- VDR Binding
- Velleman-K8055-Binding
- Wago Binding
- Wake-on-LAN Binding
- Waterkotte EcoTouch Heatpump Binding
- Weather Binding
- Wemo Binding
- Withings Binding
- XBMC Binding
- xPL Binding
- Yamahareceiver Binding
- Zibase Binding
- Z-Wave Binding
- Asterisk
- DoorBird
- FIND
- Foscam IP Cameras
- LG Hombot
- Worx Landroid
- Heatmiser PRT Thermostat
- Google Calendar
- Linux Media Players
- Osram Lightify
- Rainforest EAGLE Energy Access Gateway
- Roku Integration
- ROS Robot Operating System
- Slack
- Telldus Tellstick
- Zoneminder
- Wink Hub (rooted)
- Wink Monitoring
- openHAB Cloud Connector
- Google Calendar Scheduler
- Transformations
- XSLT
- JSON
- REST-API
- Security
- Service Discovery
- Voice Control
- BritishGasHive-Using-Ruby
- Dropbox Bundle
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.
- Rollershutter Bindings
- Squeezebox
- WAC Binding
- WebSolarLog
- Alarm Clock
- Convert Fahrenheit to Celsius
- The mother of all lighting rules
- Reusable Rules via Functions
- Combining different Items
- Items, Rules and more Examples of a SmartHome
- Google Map
- Controlling openHAB with Android
- Usecase examples
- B-Control Manager
- Spell checking for foreign languages
- Flic via Tasker
- Chromecast via castnow
- Speedtest.net integration