Example #1
0
def set_scene(address, scene):
    if scene == 'bright':
        device = gatt.connect(address)
        s = state.from_rgb(255, 255, 255, 100)
        state_map[address] = s
        s.write(device)
    elif scene == 'night':
        device = gatt.connect(address)
        s = state.from_rgb(48, 24, 96, 25)
        state_map[address] = s
        s.write(device)
    def __init__(self):
        # Find your BT device's address using 'hcitool lescan' (requires su)
        self.playbulb = gatt.connect('AB:CD:EF:01:23:45')
        # Create a new instance of the button client. Does nothing until start() is called
        self.the_button = TheButton()

        self.last_lowest = 60.0
Example #3
0
 def __init__(self):
     super(ActionThread, self).__init__()
     self.alive = threading.Event()
     self.alive.set()
     self.queue = Queue.Queue()
     self.device = gatt.connect("20:C3:8F:F3:09:98")
     self.current_state = state.from_device(self.device)
Example #4
0
 def __init__(self):
     super(ActionThread, self).__init__()
     self.alive = threading.Event()
     self.alive.set()
     self.queue = Queue.Queue()
     self.device = gatt.connect("20:C3:8F:F3:09:98")
     self.current_state = state.from_device(self.device)
Example #5
0
def get_state(address):
    if state_map.get(address) is None or state_map.get(address) is False:
        device = gatt.connect(address)
        state_map[address] = state.from_device(device)
        return state_map[address]
    else:
        return state_map[address]
    def __init__(self):
        # Find your BT device's address using 'hcitool lescan' (requires su)
        PLAYBULB_ADDRESS_1 = "AB:CD:EF:01:02:03"
        #PLAYBULB_ADDRESS_2 = "AB:CD:EF:01:02:03"
        #PLAYBULB_ADDRESS_3 = "AB:CD:EF:01:02:03"
	# Add bulbs to use to list
        self.bulb_list = []
        self.bulb_list.append(gatt.connect(PLAYBULB_ADDRESS_1))
        #self.bulb_list.append(gatt.connect(PLAYBULB_ADDRESS_2))
        #self.bulb_list.append(gatt.connect(PLAYBULB_ADDRESS_3))
        # Create a new instance of the button client. Does nothing until start() is called
        self.the_button = TheButton()
        self.last_lowest = 60.0
Example #7
0
def toggle(address):
    current_state = get_state(address)
    device = gatt.connect(address)
    new_state = state.from_device(device)

    if str(current_state.get_brightness()) != '0':
        if str(new_state.get_brightness()) == '0':
            new_state.set_brightness(current_state.get_brightness())
        else:
            new_state.set_brightness(0)
    else:
        state_map[address].set_brightness(100)
        new_state.set_brightness(100)

    new_state.write(device)

    device.disconnect()
Example #8
0
import gatt
import state
import time
import random

device = gatt.connect('20:C3:8F:F3:09:98')
s = state.from_rgb(0, 0, 0, 5)

while True:
    s.set_rgb(random.randrange(25, 100), random.randrange(25, 100),
              random.randrange(25, 100))
    s.write(device)
Example #9
0
def set_brightness(address, brightness):
    s = get_state(address)
    device = gatt.connect(address)
    s.set_brightness(brightness)
    state_map[address] = s
    s.write(device)
Example #10
0
def set_temperature(address, temperature):
    s = get_state(address)
    device = gatt.connect(address)
    s.set_temperature(temperature)
    state_map[address] = s
    s.write(device)
Example #11
0
def set_color(address, red, green, blue):
    s = get_state(address)
    device = gatt.connect(address)
    s.set_rgb(red, green, blue)
    state_map[address] = s
    s.write(device)
Example #12
0
import gatt
import state
import time
import random

device = gatt.connect('20:C3:8F:F3:09:98')
s = state.from_rgb(0, 0, 0, 5)

while True:
    s.set_rgb(random.randrange(25, 100), random.randrange(25, 100), random.randrange(25, 100))
    s.write(device)