def update_bulb(bulb): smartBulb = SmartBulb(bulb.ipAddr) if bulb.onOff: smartBulb.turn_on() else: smartBulb.turn_off() if smartBulb.is_color: hsv = rgb2hsv(int(bulb.rgbColor[0:2], 16), int(bulb.rgbColor[2:4], 16), int(bulb.rgbColor[4:6], 16)) smartBulb.hsv = hsv smartBulb.brightness = bulb.brightness
from pyHS100 import SmartPlug, SmartBulb from pprint import pformat as pf # plug = SmartPlug("192.168.31.99") # print("Hardware: %s" % pf(plug.hw_info)) # print("Full sysinfo: %s" % pf(plug.get_sysinfo())) # this prints lots of information about the device # # # print("Current state: %s" % plug.state) # plug.turn_on() # # print("Current time: %s" % plug.time) # # # print("Current LED state: %s" % plug.led) # plug.led = False # turn off led # print("New LED state: %s" % plug.led) bulb = SmartBulb("192.168.31.100") print(bulb.brightness) if bulb.is_dimmable: bulb.brightness = 100 bulb.turn_on() #print("Hardware: %s" % pf(bulb.hw_info)) #print("Full sysinfo: %s" % pf(bulb.get_sysinfo())) # this prints lots of information about the device print(bulb.is_on)
def bulb_turn_on(bulb): smartBulb = SmartBulb(bulb.ipAddr) smartBulb.turn_on() bulb.onOff = True bulb.save()
h = r.random() * 270 h = int(h) #h = 100 s = r.random() * 100 s = int(s) s = 100 for y in range(1,4): for x in range(17,25): #for x in range(1,35): addr = "10.66."+str(y)+"."+str(x) print(addr) if ( ( x == 24 ) & (y == 1 ) ): pass else: try: b = SmartBulb(addr) b.turn_on() # b.turn_off() # b.turn_off() # b.turn_off() # b.turn_off() #s = 100 b.hsv = (h,s, 100) except: pass print(i) i += 1 t.sleep(1.0)
def tpBulbOn(self, ip): bulb = SmartBulb(ip) bulb.turn_on()