-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
24 lines (16 loc) · 800 Bytes
/
main.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
import os
import fire
from home2telldus.app import app
from home2telldus.config import REPEAT_DEFAULT
from home2telldus.config import SLEEP_DEFAULT
from home2telldus.h2t import Home2TelldusClient
class Home2TelldusCli:
def run_command(self, device_name, command, email=None, password=None, repeat=REPEAT_DEFAULT, sleep_time=SLEEP_DEFAULT):
email = os.environ.get('TELLDUS_EMAIL') if email is None else email
password = os.environ.get('TELLDUS_PASSWORD') if password is None else password
with Home2TelldusClient(email, password) as client:
client.run_command(device_name, command, repeat, sleep_time)
def run_server(self):
app.run(host='0.0.0.0', use_reloader=False, threaded=True)
if __name__ == '__main__':
fire.Fire(Home2TelldusCli)