-
Notifications
You must be signed in to change notification settings - Fork 10
/
client.py
81 lines (54 loc) · 1.77 KB
/
client.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import click
from iotclient import IotClient
import db_fixture
@click.group()
def cli():
pass
@cli.command()
@click.option('--switch', help='[ON/OFF]', type=str)
@click.option('--dimmer', help='% value', type=int)
def actuate(switch, dimmer):
"""Actuation commands for example"""
iotc = IotClient()
device_id = iotc.get_device_id("ExampleFW", "123456789")
print(iotc)
attrs = {}
if switch.lower()=="on":
attrs["LightControl-On_Off-0"] = True
elif switch.lower() == "off":
attrs["LightControl-On_Off-0"] = False
if dimmer:
attrs["LightControl-Dimmer-0"] = dimmer
print(attrs)
iotc.actuate(device_id, attrs)
@cli.command()
def fixture():
"""Runs Database fixture for use in example"""
clear.callback(True, True, True, True)
db_fixture.run()
@cli.command()
@click.option('--images/--no-images', default=False, help='Remove Images', required=False)
@click.option('--devices/--no-devices', default=False, help='Remove device', required=False)
@click.option('--templates/--no-templates', default=False, help='Remove templates', required=False)
@click.option('--all/--no-all', default=False, help='Clear Database', required=False)
def clear(images, devices, templates, all):
"""Clear database entries. --help for options"""
iotc = IotClient()
if all:
iotc.clear_images()
iotc.clear_devices()
iotc.clear_templates()
return
if images:
iotc.clear_images()
if devices:
iotc.clear_devices()
if templates:
iotc.clear_templates()
if __name__ == '__main__':
# device_id = iotc.get_device_id("ExampleFW", "1.0.0", "123456789")
# attrs = {
# "Light Control: On/Off": True
# }
# iotc.actuate(device_id, attrs)
cli()