From 66def649cb6115383339d4b03bd2f84e03498cfe Mon Sep 17 00:00:00 2001 From: Cyrille Nofficial Date: Mon, 3 Feb 2020 19:31:09 +0100 Subject: [PATCH] Fix record mode blind --- part/part.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/part/part.go b/part/part.go index 657cd99..1cae726 100644 --- a/part/part.go +++ b/part/part.go @@ -81,9 +81,19 @@ func (p *LedPart) onRecord(client mqtt.Client, message mqtt.Message) { log.Errorf("unable to unmarchal %T message: %v", switchRecord, err) return } + + p.muRecord.Lock() + defer p.muRecord.Unlock() + if p.recordEnabled == switchRecord.GetEnabled() { + return + } + p.recordEnabled = switchRecord.GetEnabled() + if switchRecord.GetEnabled() { + log.Info("record mode enabled") p.led.SetBlink(2) } else { + log.Info("record mode disabled") p.led.SetBlink(0) } }