Newbie Question

I am new to python and to smart lights. I’m trying to connect an Lifx bulb through python code running on a laptop to change colors based on a set of external data. I’m having trouble with the connectivity. Can you help?

I am not a pro on python coding but I could help you with your communication with a LIFX device.

First, you have to choose how you want to communicate with it:

  • HTTP API: you need to be connected to Internet (working with LIFX cloud)
  • LAN Protocol: you can use it locally

I let you choose.


We are using LAN/ wifi

And what’s wrong with your connectivity?

I’m using python package lifxlan. The class within the module should be lifxLAN (according to GitHub)

My statement

Lifx=lifxlan(1) (creating an instance of the class)

Gives me an error module object is not callable

Importing the class from lifxlan

(from lifxlan import lifxLAN)

Gives me an error: No Module names lifxLAN

I think I might be missing a step. Or this there an ‘official’ python package I should be using?

I was a programmer many years ago and technology has changed a bit since then. I have the logic for changing the color I need to, but its connecting my code to the light bulb I’m having trouble with.


Mail]( for Windows 10

I think it is a good practice to start with Photons - Opensourcing a new framework for interacting with LIFX lights

Good luck

Photons is indeed another option :slight_smile:

As for lifxlan, are you sure you’re running the same python you installed lifxlan into?

actually, I think I know what your problem is.

LifxLAN is capitalized.

So try something like

from lifxlan import LifxLAN
lifx = LifxLAN(num_lights)

Hi Stephen

I’ve tried that

import requests

import time

from lifxlan import lifxLAN

def connect_light_source():


print(“before connect”)



print(“after connect”)

return kp_lifx


import requests

import time

from lifxlan import lifxLAN

ImportError: cannot import name lifxLAN

Mail]( for Windows 10

python is case sensitive.

You want

from lifxlan import LifxLAN
lan = LifxLAN(num_lights)

instead of

from lifxlan import lifxLAN
lan = lifxLAN(num_lights)

The difference is LifxLAN starts with a capital L

Have a look at the source code. There are samples including hello world script.
This will help immensely.
download the code from Github and have a good look.

Do you have Python 2 and 3 installed ? Which is your primary ? What pip command did you use to install it ?
If you have both 2 and 3 installed and you run pip then it may have installed into 2 but your path may go to python 3 and thus when you use the python command it can’t find the resources it needs.

pip3 will install into python 3 if you are unsure.

thanks. Got program working but think I need to switch to the HTTP API protocol. The bulb needs to travel for client’s presentations. Setting up and resetting the hardware with every new wifi network is cumbersome. Any tips?

Buy a wifi router. Cheap one will do. You don’t need internet access if you use the local lan and once onboarded to the router wifi you are good to go.

If I create a mobile hotspot on the laptop, will that work?

It might, but it’ll be difficult because you can’t easily configure the DHCP settings on a mobile hotspot. A cheap wifi router is going to have a higher chance of success.

A colleague of mine does this with his sound desk to avoid having to deal with patchy wifi at venues. They can be had for under £20. In fact we were discussing doing this with smart bulbs just the other week.

You simply fire up the wifi router, then connect your phone to it, and set up the light as normal. Then to make everything easier next time, in the router settings set a DHCP reservation for the light so it’s always given the same IP.

In future, it’s a simple case of switching on the router, waiting for it to start up, then switching on the light.