Passed
Push — smart_home ( 39eb2d...02db75 )
by Matt
02:42 queued 30s
created

PyDMXControl.smart.HomeKitLight.get_color()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
import signal
2
from threading import Thread
3
4
from pyhap.accessory import Bridge
5
from pyhap.accessory_driver import AccessoryDriver
6
7
from ._Master import MasterLight
8
from ._RGB import RGBLight
9
10
driver = None
11
12
13
def run(controller):
14
    global driver
15
    if driver is not None: return
16
17
    driver = AccessoryDriver()
18
19
    bridge = Bridge(driver, 'PyDMXControl')
20
    bridge.set_info_service(manufacturer="PyDMXControl",
21
                            model="Central Controller",
22
                            serial_number="Chans: 1->{} (All)".format(controller.next_channel - 1))
23
24
    for fixture in controller.get_all_fixtures():
25
        bridge.add_accessory(RGBLight(fixture, driver))
26
27
    bridge.add_accessory(MasterLight(controller, driver))
28
29
    signal.signal(signal.SIGTERM, driver.signal_handler)
30
    driver.add_accessory(accessory=bridge)
31
32
    thread = Thread(target=driver.start)
33
    thread.daemon = True
34
    thread.start()
35
36
37
def stop():
38
    global driver
39
    if driver is None: return
40
    driver.stop()
41