-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexamples.py
More file actions
42 lines (26 loc) · 842 Bytes
/
examples.py
File metadata and controls
42 lines (26 loc) · 842 Bytes
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
36
37
38
39
40
41
42
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
example file for different python-devoloDHC use cases
https://github.com/KiboOst/python-devoloDHC
"""
#start API and connect to your account:
import sys
sys.path.append(r'C:\path\to\api')
from pyDHC import pyDHC
DHC = pyDHC(DevoloLogin, DevoloPass)
if DHC.error: print DHC.error
#function to toggle the state or a rule:
def toggleRule(ruleName):
isActive = DHC.isRuleActive(ruleName)['result']
if isActive=='inactive':
DHC.turnRuleOnOff(ruleName, 1)
else:
DHC.turnRuleOnOff(ruleName, 0)
#then simply call toggleRule('myRule')!
#Turn a light (wall plug) on:
DHC.turnDeviceOnOff('myLight', 1)
#Check if a device is on:
state = DHC.isDeviceOn('My Wall Plug')['result']
#Start a scene:
DHC.startScene('We go out')