@@ -320,23 +320,44 @@ def __init__(self, hass: HomeAssistant) -> None:
320320
321321 # Suspend: when set, use only raw radio + spatial centroid (no k-NN, no adaptive)
322322 self ._suspend_until : float = 0.0 # monotonic timestamp when suspend ends
323+ self ._suspend_permanent : bool = False # persisted via settings store
324+
325+ # Restore persistent suspend from settings
326+ try :
327+ _st_init = self .hass .data .get (DOMAIN , {}).get (DATA_SETTINGS )
328+ if _st_init and _st_init .data .get ("databases_suspended" ):
329+ self ._suspend_permanent = True
330+ _LOGGER .info ("Databases suspended (restored from settings)" )
331+ except Exception :
332+ pass
323333
324334 # ── Suspend / reset smoothing state ─────────────────────────────────────
325335
326336 @property
327337 def suspended (self ) -> bool :
328338 """True when databases are suspended — raw radio + spatial only."""
329- return time .monotonic () < self ._suspend_until
339+ return self . _suspend_permanent or time .monotonic () < self ._suspend_until
330340
331341 def suspend_databases (self , minutes : int = 60 ) -> None :
332342 """Suspend all learned/cached databases for N minutes.
333343
334344 Clears all smoothing state and disables k-NN, adaptive learning,
335345 and scanner reliability for the duration. Only raw radio RSSI +
336346 spatial weighted centroid is used for positioning.
347+
348+ Also persists the flag so it survives HA restarts.
337349 """
338350 self .clear_smoothing_state ()
351+ self ._suspend_permanent = True
339352 self ._suspend_until = time .monotonic () + minutes * 60
353+ # Persist so it survives restarts
354+ try :
355+ _st = self .hass .data .get (DOMAIN , {}).get (DATA_SETTINGS )
356+ if _st :
357+ _st .data ["databases_suspended" ] = True
358+ self .hass .async_create_task (_st .store .async_save (_st .data ))
359+ except Exception :
360+ pass
340361 _LOGGER .info (
341362 "Databases suspended for %d minutes — raw radio + spatial centroid only" ,
342363 minutes ,
@@ -345,7 +366,16 @@ def suspend_databases(self, minutes: int = 60) -> None:
345366 def unsuspend_databases (self ) -> None :
346367 """End suspension early — resume normal pipeline."""
347368 self ._suspend_until = 0.0
369+ self ._suspend_permanent = False
348370 self .clear_smoothing_state () # start fresh when resuming too
371+ # Persist
372+ try :
373+ _st = self .hass .data .get (DOMAIN , {}).get (DATA_SETTINGS )
374+ if _st :
375+ _st .data .pop ("databases_suspended" , None )
376+ self .hass .async_create_task (_st .store .async_save (_st .data ))
377+ except Exception :
378+ pass
349379 _LOGGER .info ("Database suspension ended — full pipeline resumed" )
350380
351381 def clear_smoothing_state (self ) -> None :
0 commit comments