From 839127feb78f9ebe243d226acd417ce3b07bed86 Mon Sep 17 00:00:00 2001 From: Shane Jordan Date: Sun, 29 Nov 2026 13:40:40 +0000 Subject: [PATCH] fix(deductions): create the deductions NVS namespace at startup to stop NOT_FOUND log noise --- src/DeductionManager.cpp | 9 +++++++++ src/DeductionManager.h | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/DeductionManager.cpp b/src/DeductionManager.cpp index d8fac43..df060af 100644 --- a/src/DeductionManager.cpp +++ b/src/DeductionManager.cpp @@ -31,6 +31,15 @@ bool DeductionManager::begin() { // Static allocation — honors the no-new-heap rule. mutex_ = xSemaphoreCreateMutexStatic(&mutexBuffer_); } + if (mutex_ != nullptr) { + // Create the namespace so read-only opens don't log NOT_FOUND (#358). + Preferences prefs; + if (prefs.begin("deductions", false)) { + prefs.end(); + } else { + Serial.println("DeductionManager: could not create deductions NVS namespace"); + } + } #endif return mutex_ != nullptr; } diff --git a/src/DeductionManager.h b/src/DeductionManager.h index 3c9241d..169e81d 100644 --- a/src/DeductionManager.h +++ b/src/DeductionManager.h @@ -30,7 +30,8 @@ class DeductionManager { public: static DeductionManager& getInstance(); - // One-time init: statically allocates the tracker mutex (no new heap). + // One-time init: statically allocates the tracker mutex (no new heap) and + // creates the "deductions" NVS namespace so read-only lookups find it. // Must be called during setup() before NFC and HA tasks start. Returns // false if the mutex could not be created — deduction is then disabled // (every apply fails closed, NVS pending survives).