Пример #1
0
def switchlight(bridge, light_id, lighton):
    light = Light(bridge, light_id)

    light.xy = [1, 1]
    if lighton:
        light.brightness = 255
    else:
        light.brightness = 0
Пример #2
0
    def __init__(self, bridge, light_id, master):
        '''
        Constructor
        '''
        Light.__init__(self, bridge, light_id)
        Button.__init__(self, master)

        #self.on_off()

        #Tk.__init__(self)
        #self.state_light = self.on
        self.default_brightness = self.brightness
        self.default_color_temp = self.colortemp_k
        self.master = master

        self.lstate_var = BooleanVar(None, self.on)
        self.s1_var = IntVar(None, self.default_brightness)
        self.s2_var = IntVar(None, self.default_color_temp)
        self.s1 = Scale(root,
                        from_=0,
                        to=254,
                        orient=HORIZONTAL,
                        variable=self.s1_var,
                        command=self.set_values)
        self.s2 = Scale(root,
                        from_=2000,
                        to=6500,
                        orient=HORIZONTAL,
                        variable=self.s2_var,
                        command=self.set_temp)

        self.s1.pack()
        self.s2.pack()
        #         r1=Radiobutton(text='On', variable=lstate_var, value=True ,width=6, indicatoron=False,
        #                        command=self.switch_on).pack(side='left')
        #         r2=Radiobutton(text='Off', variable=lstate_var, value=False ,width=6, indicatoron=False,
        #                        command=self.switch_off).pack(side='left')

        self.r1 = Radiobutton(text='On',
                              variable=self.lstate_var,
                              value=True,
                              width=6,
                              indicatoron=False,
                              command=self.switch_on).pack()
        self.r2 = Radiobutton(text='Off',
                              variable=self.lstate_var,
                              value=False,
                              width=6,
                              indicatoron=False,
                              command=self.switch_off).pack()

        self.set_scale_state()
Пример #3
0
def slowchange(bridge, new_color_xy, light_id=None):
    if light_id:
        lights = [Light(bridge, light_id)]
    else:
        lights = bridge.get_light_objects()

    if not lights:
        return False

    for light in lights:
        old_x, old_y = light.xy
        break

    new_x, new_y = new_color_xy
    step = 10
    if old_x > new_x:
        step = -10
    for x in range(int(old_x * 1000), int(new_x * 1000), step):
        sleep(0.5)
        for light in lights:
            light.xy = [x / 1000, old_y]

    step = 10
    if old_y > new_y:
        step = -10
    for y in range(int(old_y * 1000), int(new_y * 1000), step):
        sleep(0.5)
        for light in lights:
            light.xy = [new_x, y / 1000]
Пример #4
0
def main():
    """
    Sets up periferals and then begins loop
    """

    # Setup Display
    segment = SevenSegment.SevenSegment(address=0x70)
    display = HT16K33.HT16K33(address=0x70)
    # Initialize the display. Must be called once before using the display.
    segment.begin()

    # Setup GPIO Button
    # pin12 --- button
    button_pin = 12
    # Numbers GPIOs by physical location
    GPIO.setmode(GPIO.BOARD)
    # Set button_pin's mode as input
    GPIO.setup(button_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)  

    # Initialize the philips bridge
    bridge = Bridge('192.168.0.10')
    # Initialise the bedroom light
    light = Light(bridge, 'Bedroom')

    loop(display, segment, light, button_pin)
Пример #5
0
    def __init__(self, lamp_id):
        self.logger = logging.getLogger('hue_utility')
        self.logger.setLevel(logging.INFO)
        self.bridge = Bridge()

        # LAMP_NAME = "Лампа"
        # lights = self.bridge.get_light_objects(mode="name")
        # self.light = lights[LAMP_NAME]
        self.light = Light(self.bridge, lamp_id)
Пример #6
0
    def set_lights(self, on=True):
        bridge = Bridge(self.hue_hostname)

        # Turn on/off all of the configured lights
        for light, time_config in self.lights:
            # Only change them if the timing info matches
            if self.check_time_config(time_config):
                Light(bridge, light).on = on

        # Turn on/off all of the configured groups
        for group, time_config in self.groups:
            if self.check_time_config(time_config):
                Group(bridge, group).on = on
Пример #7
0
def alarmsignal(bridge, light_id, color_xy=[0.675, 0.305]):
    light = Light(bridge, light_id)

    old_brightness = light.brightness
    old_xy = light.xy
    print(old_xy)

    light.xy = color_xy
    for i in range(0, 5):
        light.brightness = 254
        time.sleep(0.3)
        light.brightness = 1
        time.sleep(0.5)

    light.brightness = old_brightness
    light.xy = old_xy
Пример #8
0
    for i in lColor:
        test_light.hue = i
        sleep(2)


def setBright():
    vvalue = w.get()
    test_light.brightness = vvalue


b = Bridge('192.168.1.17')
lights = b.lights

#listLumiere()

bureau1 = Light(b, 'Sous-sol A1')
bureau2 = Light(b, 'Sous-sol A2')
test_light = Light(b, 'Sous-sol A1')
test_light.on = False
test_light.on = True
test_light.brightness = 254
test_light.saturation = 254
#test_light.effect = "colorloop"
#colorLoop()
while (True):
    colorSwitch()
#     colorLoop()

#bureau1.on = False
#bureau2.on = False
Пример #9
0
    x = time()
    for i in range(nb_flash):
        test_light.brightness = 254
        sleep(on_time)
        test_light.brightness = 0
        sleep(off_time)
    y = time()
    print(y - x)


b = Bridge('192.168.1.17')
lights = b.lights

print(lights)

test_light = Light(b, "Sous-sol A2")
test_light.brightness = 0
sleep(2)
test_light.brightness = 254
sleep(2)
test_light.brightness = 0
sleep(2)
test_light.brightness = 254
# color = [1, 6000, 12000, 18000, 24000, 30000, 36000, 42000, 48000, 52000]

# test_light.on = False
# sleep(2)
# test_light.on = True
# sleep(2)
# test_light.on = False
# sleep(2)
Пример #10
0
    def __init__(self, bridge, light_id, master, pos_row, pos_col):
        '''
        Constructor
        '''
        Light.__init__(self, bridge, light_id)
        Button.__init__(self, master)

        #self.on_off()

        #Tk.__init__(self)
        #self.state_light = self.on
        self.default_brightness = self.brightness
        self.default_color_temp = self.colortemp_k
        self.default_hue = self.hue
        self.default_saturation = self.saturation
        self.master = master

        self.lstate_var = BooleanVar(None, self.on)
        self.s1_var = IntVar(None, self.default_brightness)
        self.s2_var = IntVar(None, self.default_color_temp)
        self.s3_var = IntVar(None, self.default_hue)
        self.s4_var = IntVar(None, self.default_saturation)
        self.s1 = Scale(root,
                        label='Brightness',
                        from_=0,
                        to=254,
                        orient=HORIZONTAL,
                        variable=self.s1_var,
                        command=self.set_values)
        self.s2 = Scale(root,
                        label='Color temp',
                        from_=2000,
                        to=6500,
                        orient=HORIZONTAL,
                        variable=self.s2_var,
                        command=self.set_temp)
        self.s3 = Scale(root,
                        label='Hue',
                        from_=0,
                        to=65535,
                        orient=HORIZONTAL,
                        variable=self.s3_var,
                        command=self.set_hue)
        self.s4 = Scale(root,
                        label='Saturation',
                        from_=0,
                        to=254,
                        orient=HORIZONTAL,
                        variable=self.s4_var,
                        command=self.set_saturation)

        #         self.s1.pack()
        #         self.s4.pack()
        #         self.s2.pack()
        #         self.s3.pack()
        self.s1.grid(row=pos_row, column=pos_col)
        self.s2.grid(row=pos_row + 1, column=pos_col)
        self.s3.grid(row=pos_row, column=pos_col + 1)
        self.s4.grid(row=pos_row + 1, column=pos_col + 1)

        #         r1=Radiobutton(text='On', variable=lstate_var, value=True ,width=6, indicatoron=False,
        #                        command=self.switch_on).pack(side='left')
        #         r2=Radiobutton(text='Off', variable=lstate_var, value=False ,width=6, indicatoron=False,
        #                        command=self.switch_off).pack(side='left')

        self.r1 = Radiobutton(text='On',
                              variable=self.lstate_var,
                              value=True,
                              width=6,
                              indicatoron=False,
                              command=self.switch_on).grid(row=pos_row + 2,
                                                           column=pos_col)
        self.r2 = Radiobutton(text='Off',
                              variable=self.lstate_var,
                              value=False,
                              width=6,
                              indicatoron=False,
                              command=self.switch_off).grid(row=pos_row + 2,
                                                            column=pos_col + 1)

        self.set_scale_state()
Пример #11
0
    set_scale_state()


def set_scale_state():
    state_test_light = test_light.on
    if state_test_light:
        sa1.config(state=NORMAL, fg='#000000')
        sa2.config(state=NORMAL, fg='#000000')
    else:
        sa1.config(state=DISABLED, fg='#808080')
        sa2.config(state=DISABLED, fg='#808080')


b = Bridge('10.0.0.2')
lights = b.lights
test_light = Light(b, 5)
light_a = Light(b, 5)
light_b = Light(b, 3)

#test_light.on = True
#test_light.colortemp_k = 3200

#test_light.brightness = 50

state_test_light_a = light_a.on
default_brightness_a = light_a.brightness
default_color_temp_a = light_a.colortemp_k

state_test_light_b = light_b.on
default_brightness_b = light_b.brightness
default_color_temp_b = light_b.colortemp_k
Пример #12
0
#coding:utf-8

from tkinter import *
from distutils import command
from phue import Bridge, Light


def switch():
    print('Light switch {}'.format(check_on.get()))
    test_light.on = check_on.get()


b = Bridge('10.0.0.2')
lights = b.lights
test_light = Light(b, 5)

root = Tk()
check_on = BooleanVar()
b1 = Button(root, text='On / Off', command=switch).pack()
b2 = Checkbutton(root,
                 text='check',
                 command=switch,
                 onvalue=True,
                 offvalue=False,
                 variable=check_on,
                 image='off_button.png',
                 selectimage='on_button.png').pack()

root.mainloop()