Rust library for interacting with tasmota devices over MQTT
  • Rust 98%
  • Nix 2%
Find a file
2025-06-02 22:16:26 +02:00
.github/workflows prepare for 0.1.0 2024-10-30 19:10:02 +01:00
examples prepare for 0.1.0 2024-10-30 19:10:02 +01:00
src allow connecting with existing mqttoptions 2024-10-30 19:27:21 +01:00
.envrc init 2024-01-25 19:43:33 +01:00
.gitignore cleanup file download response handling 2024-01-26 21:08:27 +01:00
Cargo.lock remove unused dependency 2025-06-02 22:16:26 +02:00
Cargo.toml remove unused dependency 2025-06-02 22:16:26 +02:00
flake.lock flake update 2025-06-02 22:15:37 +02:00
flake.nix flake update 2025-06-02 22:15:37 +02:00
README.md prepare for 0.1.0 2024-10-30 19:10:02 +01:00

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(())
}