6 releases (breaking)

0.5.0 Jan 17, 2023
0.4.0 Nov 2, 2021
0.3.1 Aug 11, 2021
0.3.0 May 8, 2021
0.1.0 Mar 2, 2021

#749 in Hardware support

43 downloads per month

Custom license

24KB
523 lines

LG WebOs Client 0.4.0

Build Status

Simple LG webOS client written purerly in Rust. Inspired by lgtv.js

Supported commands

  • Create toast
  • Open browser
  • Turn off
  • Set channel
  • Set input
  • Set mute
  • Set volume
  • Get channel list
  • Get current channel
  • Open channel
  • Get external input list
  • Switch input
  • Is muted
  • Get volume
  • Play media
  • Stop media
  • Pause media
  • Rewind media
  • Forward media
  • Channel up
  • Channel down
  • Turn 3d on
  • Turn 3d off
  • Get services list
  • Launch an app

Example

Add to Cargo.toml

[dependencies]
lg-webos-client = "0.4.0"
tokio = { version = "1.2.0", default-features = false, features = ["full"] }

And then use the following snippet

use lg_webos_client::client::*;
use lg_webos_client::command::Command;

#[tokio::main]
async fn main() {
    env_logger::init();
    // Note: We must specify the ws protocol, and if we do not have the key, we just specify None.
    let config = WebOsClientConfig::new("ws://192.168.1.62:3000/", None);
    let client = WebosClient::new(config).await.unwrap();
    println!(
        "The key for next time you build WebOsClientConfig: {:?}",
        client.key
    );
    let resp = client.send_command(Command::GetChannelList).await.unwrap();
    println!("Got response {:?}", resp.payload);
}

The code above simply connects to tv in local network and after a successful registration lists all channels. Note that we must specify the ws protocol. If we have a key, we can pass that in the config, and the client will use said key. If no key is specified, the client will output a key generated from the device.

Contributors

  • kziemianek
  • GT3CH1

Dependencies

~5.5–8MB
~170K SLoC