Fix calculation of EmgauwaNow in relay loop

This commit is contained in:
Tobias Reisinger 2024-05-28 22:50:57 +02:00
parent 2eb38ec11e
commit bb982c4444
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE

View file

@ -36,11 +36,6 @@ async fn run_relays(app_state: &Addr<AppState>) -> Result<(), EmgauwaError> {
loop {
let now = EmgauwaNow::now();
log::debug!(
"Relay loop at {}: {}",
now.time,
printable_relay_states(&this.get_relay_states())
);
let notifier_future = notifier.notified();
pin_mut!(notifier_future);
@ -51,6 +46,8 @@ async fn run_relays(app_state: &Addr<AppState>) -> Result<(), EmgauwaError> {
.await
.is_ok();
let now = EmgauwaNow::now();
check_weekday(app_state, &mut last_weekday, &mut changed, &now).await?;
if changed {
@ -58,6 +55,12 @@ async fn run_relays(app_state: &Addr<AppState>) -> Result<(), EmgauwaError> {
this = utils::app_state_get_this(app_state).await?;
}
log::debug!(
"Relay loop at {}: {}",
now.time,
printable_relay_states(&this.get_relay_states())
);
duration_override = this
.relays
.iter_mut()