# A home that keeps company instead of watching

> When an older adult living alone runs into trouble, family often finds out days later. I built a system that detects anomalies inside the home from water and power usage rhythms alone, with no cameras, and sends the family a one-line alert.

- Published: 2026-11-11
- Client: Personal project
- Role: Design, implementation, measurement
- Period: 2026-10-21 ~ 2026-11-03
- Stack: Python, river, MQTT, SQLite, Supabase, React, Raspberry Pi
- Outcome: Mock 28-day smoke test: injected anomalies detected on 3/3 days, false alarms on 0/11 days
- Tags: anomaly-detection, iot, privacy, edge

**Why**: People refuse cameras or forget to charge wearables, and check-in calls are a burden on both sides.

**Principle**: Looking out for someone is not the same as watching them. Use only data that already flows, process it inside the home, and send only the alert out.

## Metrics

| Metrics | Value | Scope | Source |
| --- | --- | --- | --- |
| Water sensor smoke test (mock 28 days) | Injected anomalies detected on 3/3 days, false alarms on 0/11 days | Reproducible measurement | uv run solowatch smoke --db /tmp/sw.sqlite --out /tmp/sw.json (seed 42, threshold 0.995, 2026-11-02) |
| Full-chain ingestion, all 4 sensors | 32,256 published → 32,256 rows in SQLite | Reproducible measurement | tests/e2e/test_home_chain.py (mock 4 sensors × 28 days, MQTT QoS 1) |
| Feedback reflected in learning (usual morning water use) | 25.89 → 24.27 L | Reproducible measurement | uv run pytest tests/e2e/test_home_chain.py -q (test_feedback_round_trip) |
| Largest JS chunk in the web bundle | about 1.1MB → 564KB | Reproducible measurement | Development log (private), 2026-11-03 |

## Links

- Repository: https://github.com/ilyos-numon/solowatch

## 1. Situation

When something goes wrong for an older adult who lives alone, the family often finds out days later. People refuse cameras or forget to charge wearables, and check-in calls are a burden for whoever answers and whoever calls.

So I started from one idea: looking out for someone is not the same as watching them. A Raspberry Pi in the home learns the usage rhythm of 3 smart plugs and 1 water sensor, and when something differs from the usual pattern, it sends a single-line alert to the family app. The family makes the final call.

## 2. Scoping

I did not build automatic emergency calls, video or audio capture, wearables, or multi-household support. The point was to keep the machine from making the judgment. Instead I added a loop where a family member taps `It was fine` and that judgment feeds back into learning, plus an away mode that pauses both alerts and learning. So that people without the hardware could still see the whole chain, I built a separate demo that moves the entire in-home part into a virtual home inside a container. The demo reuses the same detection logic rather than a new version.

## 3. Build

| Category | What | Why |
| --- | --- | --- |
| Reused | river (online anomaly detection), Mosquitto (MQTT), SQLite, Supabase (RLS, Edge Functions), Apprise | Combine proven parts instead of writing the statistics myself |
| Fixed | Minimum deviation condition, a missing grant, the broker queue limit | Touched only the places that actually broke |
| Built | In-home daemon, feedback learning loop, family app, virtual home simulator | I needed control over what data leaves the home |

## 4. What broke

**All 11 normal days were flagged as anomalies.** Evening usage in the mock data was identical every day, so the standard deviation was 0 and even a perfectly ordinary value got the top score. I left the threshold and seed alone and added one condition, "a difference from the usual of less than 5 L is not an anomaly," along with a regression test. False alarms went from 11/11 to 0/11, and detection held at 3/3.

**32,256 messages were sent, but only 30,225 were stored.** When the subscriber fell behind, the broker was dropping messages beyond its default per-client limit of 1000. I raised the limit in the development config only, and made replay start after the subscription is confirmed. Real devices send once every 5 minutes, so they never reach this limit.

**The docs and the code said different things.** The docs claimed "the only thing that leaves the home is the alert text," but in reality two per-window totals and a 24-slot rhythm summary were also going out. I read the sending code to confirm, then corrected the docs to match the code. The more central the promise, the more plainly it should be stated.

## 5. Results

| Metric | Value | Scope | Source |
| --- | --- | --- | --- |
| Water sensor smoke test | Injected anomalies 3/3 days, false alarms 0/11 days | Mock 28 days, 14 days of training | `uv run solowatch smoke` |
| Full-chain ingestion | 32,256 → 32,256 messages | Mock 4 sensors × 28 days | `tests/e2e/test_home_chain.py` |
| Feedback reflected | Usual morning water use 25.89 → 24.27 L | 1 `It was fine` tap, then 1 daemon tick | `test_feedback_round_trip` |
| Web bundle | Largest JS chunk about 1.1MB → 564KB | Component library removed | Development log (private) |

The detection numbers come from simulated assumptions.

## 6. If I did it again

There are no real sensors and no operating records from a real household. I could not measure the false alarm rate in a real home; the next step is to install it in an actual home following the setup runbook and rebuild the same table. The "0 false alarms on ordinary days" shown in the public demo was picked from several seeds, so it is not evidence of detection performance.

One `It was fine` tap lowers the score, but it does not guarantee the alert is suppressed. I would look at feedback weighting and repeated learning. I also have not confirmed web push delivery on a real phone.

There is currently no hosted DB project, so no live demo is running. It can only be checked through the repository README and test commands. If I did it again, I would settle from the start on a deployment setup that survives free-tier pausing and deletion.
