-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol.py
35 lines (26 loc) · 1000 Bytes
/
control.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 sys
from harmony import auth
from harmony import client as harmony_client
def login_to_logitech(email, password, harmony_ip, harmony_port=5222):
"""Logs in to the Logitech service.
Args:
args: argparse arguments needed to login.
Returns:
Session token that can be used to log in to the Harmony device.
"""
token = auth.login(email, password)
if not token:
sys.exit('Could not get token from Logitech server.')
session_token = auth.swap_auth_token(
harmony_ip, harmony_port, token)
if not session_token:
sys.exit('Could not swap login token for session token.')
return session_token
def get_client(ip, session_token, port=5222):
return harmony_client.create_and_connect_client(
ip, port, session_token)
#def set_activity(session_token):
# client = harmony_client.create_and_connect_client(
# harmony_ip, harmony_port, session_token)
#def create_client():
# client.disconnect(send_close=True)