forked from mjcumming/ISY994v5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
35 lines (21 loc) · 838 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import time
from isy994.controller import Controller
url = '192.168.1.213'
#url = None # use autodiscovery
dimmer_address = '42 C8 99 1' # dimmer to flash on/off
dimmer = None
def isy_event_handler(container,item,event,*args):
print ('Event {} from {}: {} {}'.format(event,container.container_type,item.name,*args))
if container.container_type == 'Device' and event == 'add' and item.address == dimmer_address:
global dimmer
dimmer = item
try:
c = Controller(url,username='admin',password='admin',use_https=False,event_handler=isy_event_handler)
while True:
if dimmer is not None:
dimmer.set_level (0)
time.sleep(2)
if dimmer is not None:
dimmer.set_level (100)
except KeyboardInterrupt:
print("KeyboardInterrupt has been caught.")