From 57a0971c4b2a3ba167ef41d600c065e3c3e82f86 Mon Sep 17 00:00:00 2001 From: Empire Date: Sat, 17 Feb 2024 18:43:36 +0100 Subject: [PATCH] also print mode to mqtt --- rust/src/main.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index 6a71722..9170d5f 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -1,6 +1,5 @@ use std::{ - env, - sync::{atomic::AtomicBool, Arc, Mutex}, + any::Any, env, sync::{atomic::AtomicBool, Arc, Mutex} }; use chrono::{DateTime, Datelike, Duration, NaiveDateTime, Timelike}; @@ -906,6 +905,17 @@ fn update_plant_state(plantstate: &mut [PlantState; PLANT_COUNT], board: &mut st let state = &plantstate[plant]; let plant_config = config.plants[plant]; + let _ = board.mqtt_publish( + &config, + format!("/plant{}/mode", plant+1).as_str(), + match plant_config.mode { + config::Mode::OFF => "OFF".as_bytes(), + config::Mode::TargetMoisture => "TargetMoisture".as_bytes(), + config::Mode::TimerOnly => "TimerOnly".as_bytes(), + config::Mode::TimerAndDeadzone => "TimerAndDeadzone".as_bytes(), + }, + ); + let last_time = board.last_pump_time(plant); let europe_time = last_time.with_timezone(&Berlin); if europe_time.year() > 2023 {