def __init__(self, discovery_info): """Initialize the LG speakers.""" import temescal host = discovery_info.get('host') port = discovery_info.get('port') self._name = "" self._volume = 0 self._volume_min = 0 self._volume_max = 0 self._function = -1 self._functions = [] self._equaliser = -1 self._equalisers = [] self._mute = 0 self._rear_volume = 0 self._rear_volume_min = 0 self._rear_volume_max = 0 self._woofer_volume = 0 self._woofer_volume_min = 0 self._woofer_volume_max = 0 self._bass = 0 self._treble = 0 self._device = temescal.temescal(host, port=port, callback=self.handle_event) self.update()
def __init__(self, discovery_info): """Initialize the LG speakers.""" import temescal host = discovery_info.get('host') port = discovery_info.get('port') self._name = "" self._volume = 0 self._volume_min = 0 self._volume_max = 0 self._function = -1 self._functions = [] self._equaliser = -1 self._equalisers = [] self._mute = 0 self._rear_volume = 0 self._rear_volume_min = 0 self._rear_volume_max = 0 self._woofer_volume = 0 self._woofer_volume_min = 0 self._woofer_volume_max = 0 self._bass = 0 self._treble = 0 self._device = temescal.temescal(host, port=port, callback=self.handle_event) self.update()
def test_connect(host, port): """LG Soundbar config flow test_connect.""" uuid_q = Queue(maxsize=1) name_q = Queue(maxsize=1) def msg_callback(response): if response["msg"] == "MAC_INFO_DEV" and "s_uuid" in response["data"]: uuid_q.put_nowait(response["data"]["s_uuid"]) if (response["msg"] == "SPK_LIST_VIEW_INFO" and "s_user_name" in response["data"]): name_q.put_nowait(response["data"]["s_user_name"]) try: connection = temescal.temescal(host, port=port, callback=msg_callback) connection.get_mac_info() connection.get_info() details = { "name": name_q.get(timeout=10), "uuid": uuid_q.get(timeout=10) } return details except socket.timeout as err: raise ConnectionError( f"Connection timeout with server: {host}:{port}") from err except OSError as err: raise ConnectionError(f"Cannot resolve hostname: {host}") from err
def _connect(self): """Perform the actual devices setup.""" self._device = temescal.temescal( self._host, port=self._port, callback=self.handle_event ) self._device.get_product_info() self._device.get_mac_info() self.update()
def main(args): parser = argparse.ArgumentParser(description='Transfer releases from FTP') parser.add_argument('--ip', action='store', dest='ip', required=True, help='IP of the LG soundbar') parser.add_argument('--endpoint', action='store', dest='endpoint', required=True, choices=[ 'mac_info', 'mem_mon_info', 'info', 'settings', 'product_info', 'c4a_info', 'build_info', 'option_info', 'update_info' ], help=textwrap.dedent(""" Endpoint of the LG soundbar API to query. Following endpoints are available: endpoint mac_info - s_wired_mac - s_wireless_mac - s_bt_mac - s_uuid endpoint mem_mon_info - i_free_drop - i_free_reboot - i_load - i_total - i_buffers - i_free - i_cache - i_warn - i_limit endpoint info - b_mute - b_update - i_curr_func - i_vol - i_vol_max - i_vol_min - s_user_name endpoint settings - b_drc - b_auto_vol - b_auto_display - b_auto_power - b_tv_remote - b_conn_bt_limit - b_bt_standby - b_night_mode - i_woofer_max - i_woofer_min - i_woofer_level - i_c4a_sharing - i_av_sync - i_sleep_time - i_curr_eq - s_ipv4_addr - s_user_name endpoint product_info - i_network_type - i_model_no - i_model_type endpoint c4a_info - i_agree - s_timezone endpoint build_info - i_beta - i_package_ver - s_platform - s_lgcode - s_touch - s_package - s_dsp - s_c4a - s_hdmi - s_lgrev - s_time - s_main - s_micom - s_rear_rx - s_rear_tx - s_woofer_rx - s_woofer_tx - s_meq - s_demo - s_peq endpoint option_info - i_length - s_option """)) arguments = parser.parse_args() speaker = temescal.temescal(arguments.ip, callback=callback) if arguments.endpoint == 'mac_info': speaker.get_mac_info() elif arguments.endpoint == 'mem_mon_info': speaker.get_mem_mon_info() elif arguments.endpoint == 'info': speaker.get_info() elif arguments.endpoint == 'settings': speaker.get_settings() elif arguments.endpoint == 'product_info': speaker.get_product_info() elif arguments.endpoint == 'c4a_info': speaker.get_c4a_info() elif arguments.endpoint == 'build_info': speaker.get_build_info() elif arguments.endpoint == 'option_info': speaker.get_option_info() elif arguments.endpoint == 'update_info': speaker.get_update_info()