also print mode to mqtt

This commit is contained in:
Empire 2024-02-17 18:43:36 +01:00
parent 556e64740a
commit 57a0971c4b

View File

@ -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 {