mirror of
https://codeberg.org/icewind/tasmota-mqtt-client.git
synced 2026-06-03 18:24:09 +02:00
config export
This commit is contained in:
parent
04d8752b33
commit
549c533076
7 changed files with 721 additions and 9 deletions
31
examples/backup.rs
Normal file
31
examples/backup.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use clap::Parser;
|
||||
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)),
|
||||
)?;
|
||||
let file = client
|
||||
.download_config(&args.device, &args.device_password)
|
||||
.await?;
|
||||
|
||||
println!("downloaded {}", file.name);
|
||||
if let Err(e) = std::fs::write(&file.name, file.data) {
|
||||
eprintln!("Error while saving {}: {:#}", file.name, e);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue