コード例 #1
0
ファイル: __main__.py プロジェクト: rooi/pyharmony
def login_to_logitech(args):
    """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.
    """

    file = open('harmonyLogin.txt', 'r')
    email = file.readline().strip()
    #print email
    #print args.email
    password = file.readline().strip()
    #print password
    #print args.password

    print "Create token"
    #token = auth.login(args.email, args.password)
    token = auth.login(email, password)
    if not token:
        sys.exit('Could not get token from Logitech server.')

    print "Create session token"
    session_token = auth.swap_auth_token(
        args.harmony_ip, args.harmony_port, token)
    if not session_token:
        sys.exit('Could not swap login token for session token.')

    return session_token
コード例 #2
0
 def login(self):
     self.token = auth.login(self.username, self.password)
     if not self.token:
         raise Exception('Could not log in to the harmony service')
     session_token = auth.swap_auth_token(self.ip, self.port, self.token)
     self.harmony_client = client.create_and_connect_client(self.ip, self.port, self.token)
     if not self.harmony_client:
         raise Exception('Could not log in to the harmony device')
コード例 #3
0
ファイル: __main__.py プロジェクト: WisdomWolf/pyharmony
def login_to_logitech_site(email, password, harmony_ip, harmony_port):
    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
コード例 #4
0
def get_client(harmony_ip, harmony_port, email, password):
    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.')
    client = harmony_client.create_and_connect_client(
        harmony_ip, harmony_port, token)
    return client
コード例 #5
0
def login_to_logitech(args):
	"""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(args.email, args.password)
	if not token:
		sys.exit('Could not get token from Logitech server.')

	session_token = auth.swap_auth_token(args.harmony_ip, args.harmony_port, token)
	if not session_token:
		sys.exit('Could not swap login token for session token.')

	return session_token
コード例 #6
0
ファイル: __main__.py プロジェクト: anonfunc/pyharmony
def login_to_logitech(args):
    """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(args.email, args.password)
    if not token:
        sys.exit('Could not get token from Logitech server.')

    session_token = auth.swap_auth_token(args.harmony_ip, args.harmony_port,
                                         token)
    if not session_token:
        sys.exit('Could not swap login token for session token.')

    return session_token
コード例 #7
0
ファイル: remote.py プロジェクト: christiandt/Desktop-Harmony
from harmony import auth
from harmony import client

username = "******"
password = "******"

ip = "10.0.0.0"
port = "5222"

token = auth.login(username, password)
session_token = auth.swap_auth_token(ip, port, token)
harmony_client = client.create_and_connect_client(ip, port, token)

configuration = harmony_client.get_config()

counter = 0
for activity in configuration['activity']:
	print "%i: %s" % (counter, activity['label'])
	counter += 1

selection = int(input("Activity: "))
selected_id = int(configuration['activity'][selection]['id'])

harmony_client.start_activity(selected_id)

harmony_client.disconnect(send_close=True)