1 unstable release
0.1.0 | Oct 30, 2024 |
---|
#1700 in Network programming
115 downloads per month
24KB
448 lines
tasmota-mqtt-client
Rust library for interacting with tasmota devices over MQTT
Supported features
- Device discovery
- Query device name
- Query device ip
- Backup device config
Example
use std::pin::pin;
use tasmota_mqtt_client::{DeviceUpdate, Result, TasmotaClient};
use tokio::join;
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() -> Result<()> {
let client = TasmotaClient::connect(
"mqtt.example.com",
1883,
Some(("mqtt_username", "mqtt_password")),
)
.await?;
let mut discovery = pin!(client.devices());
while let Some(update) = discovery.next().await {
match update {
DeviceUpdate::Added(device) => {
let (ip, name) = join!(client.device_ip(&device), client.device_name(&device));
println!("discovered {}({device}) with ip {}", name?, ip?);
}
DeviceUpdate::Removed(device) => {
println!("{device} has gone offline");
}
}
}
Ok(())
}
Dependencies
~7–16MB
~200K SLoC