Hello. I’m getting started working on a network application that can execute python scrip to control my LIFX devices. I’m familiar with programming in other languages but i wanted to take this opportunity to started with Python and Linux. I’ve been going over the open source API here, and have create a very simple code to get started but have run into my first hurdle. I am able to execute the Python scrips in the examples and lifxlan folders from the Terminal with no problem, but when i try to run my own nothing happens and when i debug them it IDLE 3 i get this error.
from lifxlan import LifxLAN
ImportError: cannot import name ‘LifxLAN’
The weird thing is if i open up an example in IDLE 3 i can a similar error. Could anyone tell me what i’m doing wrong? Here is my code.
#!/usr/bin/env python # coding=utf-8 import sys from lifxlan import LifxLAN def main(): #number of lights from selector or 1 by default num_lights = 1 # instantiate LifxLAN client, num_lights may be None (unknown). # In fact, you don't need to provide LifxLAN with the number of bulbs at all. # lifx = LifxLAN() works just as well. Knowing the number of bulbs in advance # simply makes initial bulb discovery faster. print("Discovering lights...") lifx = LifxLAN(num_lights) # get devices print("Discovering lights...") light1 = lifx.get_lights(num_lights) if light1.get_power() == "off": light1.set_power("on") print("Light was off.\nNow it's on") else: light1.set_power("off") print("Light was on.\nNow it's off") if __name__=="__main__": main()