new featres

This commit is contained in:
Jakob Gegeniger committed 2026-09-09 23:21:48 +02:00
1 parent 92423c52de
commit f93a8aaabd
6 files changed
+76 -14

No files matched your search

+41
View File
@@ -118,7 +118,14 @@ int main(int argc, char* argv[]) {
return EXIT_SUCCESS;
}
enum MuteState {
WaitForUnmute,
WaitForMute,
WaitForNextDay,
};
void processPromo(MqttChannel& mqtt, SeqLogger& log) {
auto muterS = MuteState::WaitForUnmute;
Tick tmu(1min);
Tick tn(1s);
Tick tsf(30min);
auto& serCmds = mqtt.getSerCommands();
@@ -143,6 +150,40 @@ void processPromo(MqttChannel& mqtt, SeqLogger& log) {
if (tn.tick()) {
mqtt.sendStatusMessage(Mode);
}
if (tmu.tick()) {
auto now = std::chrono::system_clock::now();
std::time_t time = std::chrono::system_clock::to_time_t(now);
std::tm* lTime = std::localtime(&time);
int current_hour = lTime->tm_hour;
switch (muterS) {
case WaitForUnmute:
if (current_hour >= 9) {
fmt::println("[09:00 Threshold] Unmute");
log.sendEvent("Unmute", "Time for unmute");
IoStat->Mute = false;
muterS = WaitForMute;
}
break;
case WaitForMute:
if (current_hour >= 21) {
fmt::println("[21:00 Threshold] Mute");
log.sendEvent("Mute", "Time for mute");
IoStat->Mute = true;
muterS = WaitForNextDay;
}
break;
case WaitForNextDay:
if (current_hour < 1) {
fmt::println("[01:00 Threshold] new day");
muterS = WaitForUnmute;
}
break;
default:
break;
}
}
}
}