get ip and name

This commit is contained in:
Robin Appelman 2024-01-26 23:05:39 +01:00
commit 054b8e277c
3 changed files with 84 additions and 1 deletions

View file

@ -2,6 +2,7 @@ use clap::Parser;
use std::pin::pin;
use tasmota_mqtt_client::DeviceUpdate;
pub use tasmota_mqtt_client::{Result, TasmotaClient};
use tokio::join;
use tokio_stream::StreamExt;
#[derive(Debug, Parser)]
@ -26,7 +27,8 @@ async fn main() -> Result<()> {
while let Some(update) = discovery.next().await {
match update {
DeviceUpdate::Added(device) => {
println!("discovered {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");