def _get_client(self): self.l_info("get_client","Initializing PyHarmony Client") harmony_client.logger.setLevel(logging.INFO) self.last_activity_method = self.parent.activity_method try: if self.parent.activity_method == 2: self.client = harmony_client.create_and_connect_client(self.host, self.port, self._set_current_activity) else: self.client = harmony_client.create_and_connect_client(self.host, self.port) if self.client is False: self.l_error('get_client','harmony_client returned False, will retry connect during next shortPoll interval') self._set_st(0) self._close_client() self.client_status = "failed" return False except: self.l_error('get_client','Failed to connect to host "{}" port "{}"'.format(self.host,self.port),True) self._set_st(0) self._close_client() self.client_status = "failed" return False self.l_info("get_client","PyHarmony client= " + str(self.client)) self._set_st(1) # Setup activities and devices self.init_activities_and_devices() self._get_current_activity() self.client_status = True # Hang around until asked to quit self.l_debug('_get_client','Wait until we are told to stop') self.event.wait() self.l_debug('_get_client','Event is done waiting, Goodbye')
def process(self, activity): client = harmony_client.create_and_connect_client( HARMONY_IP, HARMONY_PORT, HARMONY_TOKEN) for a in client.get_config()['activity']: if a['label'] == activity: self.output.append('starting activity {0}'.format(activity)) client.start_activity(a['id']) client.disconnect(send_close=True)
def ha_get_client(token, ip, port): """Connect to the Harmony and return a Client instance. Args: ip (str): Harmony hub IP address port (str): Harmony hub port token (str): Session token obtained from hub Returns: object: Authenticated client instance. """ client = harmony_client.create_and_connect_client(ip, port, token) return client
def get_client(ip, port): """Connect to the Harmony and return a Client instance. Args: harmony_ip (str): Harmony hub IP address harmony_port (str): Harmony hub port Returns: object: Authenticated client instance. """ token = "unused" client = harmony_client.create_and_connect_client(ip, port, token) return client
def get_client(self): token = auth.login(self.email, self.password) if not token: sys.exit('Could not get token from Logitech server.') session_token = auth.swap_auth_token( self.harmony_ip, self.harmony_port, token) if not session_token: sys.exit('Could not swap login token for session token.') client = harmony_client.create_and_connect_client( self.harmony_ip, self.harmony_port, session_token) return client
def ha_get_client(ip, port): """Connect to the Harmony and return a Client instance. Args: ip (str): Harmony hub IP address port (str): Harmony hub port token (str): Session token obtained from hub Returns: object: Authenticated client instance. """ client = harmony_client.create_and_connect_client(ip, port) return client
def ha_get_client(token, harmony_ip, harmony_port): """Connect to the Harmony and return a Client instance. Args: email (str): Email address used to login to Logitech service password (str): Password used to login to Logitech service harmony_ip (str): Harmony hub IP address harmony_port (str): Harmony hub port Returns: object: Authenticated client instance. """ client = harmony_client.create_and_connect_client(harmony_ip, harmony_port, token) return client
def get_client(ip, port, activity_callback=None): """Connect to the Harmony and return a Client instance. Args: harmony_ip (str): Harmony hub IP address harmony_port (str): Harmony hub port activity_callback (function): Function to call when the current activity has changed. Returns: object: Authenticated client instance. """ client = harmony_client.create_and_connect_client(ip, port, activity_callback) return client
def create_client(): log_message = f"Connect harmony client to {HARMONY_IP}:{PORT}" logging.info(log_message) client = Client.create_and_connect_client(ip_address=HARMONY_IP, port=PORT, activity_callback=handle_change) activity = client.get_current_activity() _R.set("activity", activity) if activity in ACTIVITIES: state = "extended" else: state = "retracted" _R.set("state", state) return client
def get_client(ip, port, activity_callback=None): """Connect to the Harmony and return a Client instance. Args: harmony_ip (str): Harmony hub IP address harmony_port (str): Harmony hub port activity_callback (function): Function to call when the current activity has changed. Returns: object: Authenticated client instance. """ client = harmony_client.create_and_connect_client(ip, port, activity_callback) return client
def get_client(email, password, harmony_ip='HarmonyHub', harmony_port=5222): """Gets a client object used to interact with Logitech Args: email: Email address to login to Logitech password: Password to login to Logitech harmony_ip: IP address of Harmony Hub harmony_port: port of Harmony Hub (default: 5222) Returns: Client object used to control the Harmony device. """ token = login_to_logitech(email, password, harmony_ip, harmony_port) client = harmony_client.create_and_connect_client(harmony_ip, harmony_port, token) return client
def get_client(email, password, harmony_ip='HarmonyHub', harmony_port=5222): """Gets a client object used to interact with Logitech Args: email: Email address to login to Logitech password: Password to login to Logitech harmony_ip: IP address of Harmony Hub harmony_port: port of Harmony Hub (default: 5222) Returns: Client object used to control the Harmony device. """ token = login_to_logitech(email, password, harmony_ip, harmony_port) client = harmony_client.create_and_connect_client( harmony_ip, harmony_port, token) return client
def get_client(args): """Connect to the Harmony and return a Client instance.""" token = login_to_logitech(args) client = harmony_client.create_and_connect_client( args.harmony_ip, args.harmony_port, token) return client
def get_client(args): """Connect to the Harmony and return a Client instance.""" token = login_to_logitech(args) client = harmony_client.create_and_connect_client( args.harmony_ip, args.harmony_port, token) return client