Lifx WiFi Lightbulbs

While the LIFX LED bulbs are not part of the MySensors network, they are still part of the Smart Home. LIFX bulbs connect directly to the Wi-Fi network and require no additional hardware.

We use the LIFX application for additional effects, but keep simple, default lighting settings as quick actions in OpenHAB.

The bulbs are allocated Static IP addresses and physically left on all of the time. They are controlled by OpenHAB with executed shell scripts.

In our case, the lounge LIFX bulbs have been retrofitted into what was two 150W Halogen light fittings. Originally, 300w of power was being consumed when the lights were on.

As bulbs, the LIFX product is more expensive to buy, but with all four on for a total of 44w, they’re a lot cheaper to power. Not to mention the color effects, software based LED dimming and countless automation opportunities. Standby power consumption with the 4 remaining physically on all the time is only ~2.8w

Incidentally, the remainder of the house has also been moved over to Philips LED bulbs and at only 14w a piece, we can run the entire house on less than what it used cost to run two 100w incandescent bulbs.

OpenHAB Scripts for quick Off, On, Movie, Half White settings

rule "Lounge Lights"
when
    Item Lounge_Lights received command
then
    if (receivedCommand==0) {

        executeCommandLine("/etc/openhab/configurations/scripts/lifx/lounge_off.sh");
        say("Turning lounge lights off");
    }
    else if (receivedCommand==1) {

        executeCommandLine("/etc/openhab/configurations/scripts/lifx/lounge_on.sh");
        say("Turning lounge lights on");
    }
    else if (receivedCommand==2) {

        executeCommandLine("/etc/openhab/configurations/scripts/lifx/lounge_movie.sh");
        say("Setting lounge lights to movie mode");
    }
    else if (receivedCommand==3) {

        executeCommandLine("/etc/openhab/configurations/scripts/lifx/lounge_half_white.sh");
        say("Setting lounge lights to half white");
    }
end
python /etc/openhab/configurations/scripts/lifx/lifx-simple/set_colour.py 192.168.1.174 0 0 100 6500 &
python /etc/openhab/configurations/scripts/lifx/lifx-simple/set_colour.py 192.168.1.172 0 0 100 6500 &
python /etc/openhab/configurations/scripts/lifx/lifx-simple/set_colour.py 192.168.1.173 0 0 100 6500 &
python /etc/openhab/configurations/scripts/lifx/lifx-simple/set_colour.py 192.168.1.171 0 0 100 6500 &

exit 0
#!/usr/bin/env python

"""
Simple implementation of colour-sending functionality,
without the ACK/retry functionality. Send only, no listen.

Author: Petr Klus
"""
RETRIES  = 5
DELAY    = 0.05
UDP_PORT = 56700


import socket
import time
import sys
import random

from tools import gen_packet

SEQ_NUM = random.randint(0, 255)

def set_HSBK(bulb_ip, hue, sat, bri, kel=3500):
    print hue, sat, bri, kel
    for _ in range(RETRIES):
        sock.sendto(gen_packet(hue, sat, bri,kel,SEQ_NUM), (bulb_ip, UDP_PORT))
        time.sleep(DELAY)

if __name__ == "__main__":
    print sys.argv

    # different for each execution

    print "Using sequence number:", SEQ_NUM
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP

    bulb_ip = sys.argv[1]

    if len(sys.argv) == 2:
        # demo
        print "Testing H"
        for x in range(80):
            set_HSBK(bulb_ip, 360/80*x, 100, 100)
            time.sleep(0.1)

        print "Testing S"
        for x in range(21):
            set_HSBK(bulb_ip, 120, x*5, 100)
            time.sleep(0.1)

        print "Testing B"
        for x in range(11):
            set_HSBK(bulb_ip, 360, 100, x*10)
            time.sleep(0.1)

        print "Testing K"
        for x in range(10):
            set_HSBK(bulb_ip, 360, 0, 100, 6500/10*x+2500)
            time.sleep(0.3)
    else:
        bulb_ip            = sys.argv[1]
        hue, sat, bri, kel = map(int, sys.argv[2:])

        set_HSBK(bulb_ip, hue, sat, bri, kel)
Last modified April 10, 2023: more content (59f5057)