Crates.io | lg-webos-client |
lib.rs | lg-webos-client |
version | 0.5.0 |
source | src |
created_at | 2021-03-02 08:33:15.640709 |
updated_at | 2023-01-17 19:51:13.096833 |
description | LG webOS client |
homepage | |
repository | https://github.com/kziemianek/lg-webos-client |
max_upload_size | |
id | 362535 |
size | 51,074 |
Simple LG webOS client written purerly in Rust. Inspired by lgtv.js
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.