Fix record mode blind

This commit is contained in:
Cyrille Nofficial 2020-02-03 19:31:09 +01:00
parent b9123ce18f
commit 66def649cb

View File

@ -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)
}
}