## NetcastClient

Client to interact with necast TVs host has to include a valid port number. By default LG TVs use 8080 so make sure to specify that eg. 192.168.1.3:8080

Following options are supported:

interface Options {
  timeout: 2000;
}
**Kind**: global class * [NetcastClient](#NetcastClient) * [new NetcastClient(host, options)](#new_NetcastClient_new) * [.wrap_command(command_type, command, session)](#NetcastClient+wrap_command) * [.send_to_tv(message_type, message, payload)](#NetcastClient+send_to_tv) * [.display_pair_code()](#NetcastClient+display_pair_code) * [.get_session(access_token)](#NetcastClient+get_session) * [.query_data(query)](#NetcastClient+query_data) * [.send_command(command, session)](#NetcastClient+send_command) * [.change_channel(channel, session)](#NetcastClient+change_channel) * [.get_current_channel(session)](#NetcastClient+get_current_channel) ### new NetcastClient(host, options)

Creates a new NetcastClient instance

| Param | Type | Description | | --- | --- | --- | | host | string |

The host

| | options | 2000 |

The options

| ### netcastClient.wrap\_command(command_type, command, session)

Wraps the given command into an XML block ready to send to the TV

**Kind**: instance method of [NetcastClient](#NetcastClient) | Param | Type | Default | Description | | --- | --- | --- | --- | | command_type | LG\_HANDLE | |

LG_HANDLE

| | command | Channel | |

either a LG_COMMAND or other payload, such as Channel

| | session | string | null |

the current session id. if not specified, the command will be unauthenticated

| ### netcastClient.send\_to\_tv(message_type, message, payload)

Sends the given message to the TV. message has to be in XML format Will return a javascript object with the result, or throw an exception

**Kind**: instance method of [NetcastClient](#NetcastClient) | Param | Type | Default | Description | | --- | --- | --- | --- | | message_type | string | |

Type of the message to send, eg 'data', 'command', 'auth'

| | message | string | null |

Message to send in XML string format

| | payload | object | |

Payload & (GET) parameters to send

| ### netcastClient.display\_pair\_code()

Issues a command to the TV to display the pair code // access token

**Kind**: instance method of [NetcastClient](#NetcastClient) ### netcastClient.get\_session(access_token)

Retrieves (or creates) the current session used for interacting with the TV

**Kind**: instance method of [NetcastClient](#NetcastClient) | Param | Type | Default | Description | | --- | --- | --- | --- | | access_token | string | null |

Access token aka pair code

| ### netcastClient.query\_data(query)

Issues a query command to the TV to retrieve current information such as channel, volume, etc

**Kind**: instance method of [NetcastClient](#NetcastClient) | Param | Type | Description | | --- | --- | --- | | query | LG\_QUERY |

What to query. See LG_QUERY type

| ### netcastClient.send\_command(command, session)

Sends the given command to the TV To issue commands, you need a valid session id. To retrieve that, use get_session() paired with the access_token of the TV To get the access_token, use display_pair_code()

**Kind**: instance method of [NetcastClient](#NetcastClient) | Param | Type | Description | | --- | --- | --- | | command | LG\_COMMAND |

The command to send, see LG_COMMAND type

| | session | string |

Session id

| ### netcastClient.change\_channel(channel, session)

Changes channel to the given channel

**Kind**: instance method of [NetcastClient](#NetcastClient) | Param | Type | Description | | --- | --- | --- | | channel | Channel |

The channel to switch to. Has to be in a specific format, see Channel type

| | session | string |

Session id

| ### netcastClient.get\_current\_channel(session)

Retrieves the current channel information from the TV

**Kind**: instance method of [NetcastClient](#NetcastClient) | Param | Type | Description | | --- | --- | --- | | session | string |

The session

|