From 0128fb535fc56bb4cb4aaba1758a047708805ff6 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sun, 27 Sep 2020 16:08:26 +0200 Subject: [PATCH] Check for zero-value in recalc_stops --- main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 559daee..a944543 100644 --- a/main.c +++ b/main.c @@ -243,7 +243,9 @@ static void set_temperature(struct context *ctx) { static void recalc_stops(struct context *ctx, time_t now) { time_t day = now - (now % 86400); time_t true_end = ctx->stop_time + ctx->duration; - if (now > true_end) { + if (ctx->stop_time == 0) { + // First calculation + } else if (now > true_end) { day += 86400; } else if (day < true_end) { return;