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
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')
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
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
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
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)