mirror of
https://codeberg.org/icewind/tasmota-mqtt-client.git
synced 2026-06-03 10:14:10 +02:00
33 lines
812 B
Rust
33 lines
812 B
Rust
use clap::Parser;
|
|
use hex_fmt::HexFmt;
|
|
pub use tasmota_mqtt_client::{Result, TasmotaClient};
|
|
|
|
#[derive(Debug, Parser)]
|
|
struct Args {
|
|
hostname: String,
|
|
port: u16,
|
|
username: String,
|
|
password: String,
|
|
device: String,
|
|
device_password: String,
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
let args = Args::parse();
|
|
let client = TasmotaClient::connect(
|
|
&args.hostname,
|
|
args.port,
|
|
Some((&args.username, &args.password)),
|
|
)
|
|
.await?;
|
|
let file = client
|
|
.download_config(&args.device, &args.device_password)
|
|
.await?;
|
|
|
|
println!("downloaded {} with hash {}", file.name, HexFmt(file.md5));
|
|
if let Err(e) = std::fs::write(&file.name, file.data) {
|
|
eprintln!("Error while saving {}: {:#}", file.name, e);
|
|
}
|
|
Ok(())
|
|
}
|