From 940cf0822698505c75378c41a157834cd2d6277e Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sun, 20 Sep 2020 03:50:47 +0200 Subject: [PATCH] Account when forcing high/low state --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 87d5ceb..4284149 100644 --- a/main.c +++ b/main.c @@ -233,12 +233,12 @@ static void update_temperature(struct context *ctx) { time_t now = time(NULL); int temp, temp_pos; double time_pos; - + recalc_stops(ctx, now); switch (ctx->state) { case HIGH_TEMP: - if (now < ctx->stop_time && now > ctx->start_time) { + if (now <= ctx->stop_time && now > ctx->start_time + ctx->duration) { temp = ctx->high_temp; break; } @@ -257,7 +257,7 @@ static void update_temperature(struct context *ctx) { temp = ctx->high_temp - temp_pos; break; case LOW_TEMP: - if (now > ctx->stop_time || now < ctx->start_time) { + if (now > ctx->stop_time + ctx->duration || now <= ctx->start_time) { temp = ctx->low_temp; break; }