diff --git a/core/loadpoint.go b/core/loadpoint.go index 9203f8d2f..7b5517a7e 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -1792,8 +1792,10 @@ func (lp *Loadpoint) startWakeUpTimer() { // stopWakeUpTimer stops wakeUpTimer func (lp *Loadpoint) stopWakeUpTimer() { - lp.log.DEBUG.Printf("wake-up timer: stop") - lp.wakeUpTimer.Stop() + if lp.wakeUpTimer.Running() { + lp.log.DEBUG.Printf("wake-up timer: stop") + lp.wakeUpTimer.Stop() + } } func (lp *Loadpoint) shouldBeConsistent() bool { diff --git a/core/timer.go b/core/timer.go index 419603613..cceebed0c 100644 --- a/core/timer.go +++ b/core/timer.go @@ -57,6 +57,13 @@ func (m *Timer) Stop() { m.started = time.Time{} } +func (m *Timer) Running() bool { + m.Lock() + defer m.Unlock() + + return !m.started.IsZero() +} + // Elapsed checks if the timer has elapsed and if resets its status func (m *Timer) Elapsed() WakeUpEvent { m.Lock()