Built to Be Efficient - TheThinkingHome/device_sentinel GitHub Wiki
Built to Be Efficient
Device Sentinel watches every single device in your home, tracks every battery, and records a running history of your radio links.
If you run Home Assistant on a mini-PC with a fast SSD, this workload is completely invisible. But if you run it on a Raspberry Pi with a standard SD card, constant, tiny data writes are exactly what burns those cards out.
We knew this from the beginning. Device Sentinel was designed to treat your flash storage with extreme prejudice, reducing write wear to the absolute minimum while still keeping an airtight record of your home.
Here is how we protect your hardware, and how you can tune it.
Separating the Noise from the News
If a chatty motion sensor updates its "last heard" clock every ten seconds, writing its entire three-month baseline history to disk every time it moves would be a disaster.
So, Device Sentinel splits the workload into two buckets:
- The Fast-Moving Clocks: This tiny bucket holds only the numbers that change constantly: the activity clock, the current signal reading, and the live battery level. This bucket takes the routine beatings.
- The Long-Term History: This much larger bucket holds everything the system has learned: the daily history, the baseline rhythms, the freeze verdicts, and the problem list. Because the fast-moving clocks are separated out, this massive archive is spared the churn of ordinary activity. It only writes to disk when something important actually changes.
By splitting the data, routine write volume drops by roughly 64 percent.
Batching the Routine Stuff
Even with the split, writing to disk every time a sensor blinks is wasteful.
Instead, Device Sentinel holds routine clock updates in memory and writes them to the tiny clock bucket in batches on a schedule (15 minutes by default). Historically, this simple batching reduced nightly disk writes from roughly 515 down to just 36.
But what if the power goes out?
We don't batch emergencies. If a device freezes, a battery crosses your danger threshold, or a problem lands on your to-do list, Device Sentinel writes that immediately.
The only thing exposed during a sudden power cut is the routine clock progress waiting in the batch window. And because those are just clocks, they automatically repair themselves the very next time each device reports in. Nothing learned is lost.
The Two Dials You Care About
You have full control over the storage footprint via two settings on the Advanced screen.
1. Storage Write Interval
This is your batch timer. It dictates how long routine changes are held in memory before being flushed to disk.
- On an SD Card: Crank this up to 30 or 60 minutes. You will drastically reduce wear and tear on your card.
- On an SSD: Leave it at the default 15, or drop it to 5 if you want to narrow the tiny window of routine data exposed to a power cut.
2. How Much History to Keep
This sets how many days of history are retained, which controls the final size of your long-term history file.
- 30 Days: Bare minimum to establish rhythms and signal floors. (Recommended for SD Cards)
- 90 Days: The default. Great for watching battery decay over a season.
- 360 Days: Only do this if you have a fast SSD, plenty of RAM, and want to chart a year of signal health.
(Note: Lowering this setting takes effect at the next midnight rollover, not the moment you move the slider. If you make a mistake, you have until midnight to put it back before any history is permanently trimmed).