Esempio n. 1
0
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
Esempio n. 2
0
  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)


Esempio n. 3
0
import argparse, sys
from pyHS100 import SmartPlug, SmartBulb
from pprint import pformat as pf

parser = argparse.ArgumentParser()
parser.add_argument('--ip', help='IP of smart bulb')
parser.add_argument('--state', help='Change state to on or off')
parser.add_argument('--color', help='Change color of bulb')
args = parser.parse_args()
print(args.ip)
bulb = SmartBulb(args.ip)
print(bulb.hsv)
if args.state == "off":
    bulb.state = "OFF"
if args.state == "on":
    bulb.state = "ON"
if args.color == "red":
    if bulb.is_color:
        bulb.hsv = (0, 100, 100)  # set to red
if args.color == "orange":
    if bulb.is_color:
        bulb.hsv = (12, 100, 100)  # set to orange
if args.color == "yellow":
    if bulb.is_color:
        bulb.hsv = (60, 100, 100)  # set to yellow
if args.color == "blue":
    if bulb.is_color:
        bulb.hsv = (209, 100, 100)  # set to blue