In an era of relentless push notifications and glowing screens, accessing personal health data often means unlocking a phone and diving into a rabbit hole of apps. LifeHub is a personal analytics ecosystem designed to solve this by bridging the digital and physical worlds.
It aggregates complex health and lifestyle data—from Apple HealthKit metrics to food delivery spending—and presents it on an always-on, low-power E-Ink display in your home. It is a "calm technology" solution: a dashboard that is there when you need it, updated automatically, and powered by a battery that sips energy intelligently.
The Architecture: A Tale of Two Systems
The LifeHub ecosystem is built on a "Brain and Display" architecture, separated by a thin cloud layer.
1. The Brain (iOS App): A custom Swift application that serves as the central data aggregator. It lives on your iPhone, processing raw data into meaningful metrics.
2. The Bridge (GitHub Gist): A secure, private JSON file hosted on GitHub serves as the dead drop for data transfer.
3. The Display (Raspberry Pi & E-Ink): A hardware-optimized Python application that wakes up, fetches the data, renders the visual interface, and goes back to sleep.
Part 1: The Data Aggregator (iOS App)
The heart of the system is the LifeHub iOS app. Built with SwiftUI and SwiftData, it doesn't just read steps; it contextualizes your lifestyle.
Data Sources & Logic
The app pulls from two distinct worlds:
* Physical Health (HealthKit): It aggregates steps, active energy, sleep consistency (duration and wake times), and weight trends. It uses forward-filling logic for weight (so you don't need to weigh yourself daily) and calculates complex metrics like "Active Day Ratios" (days with >8,000 steps).
* Financial/Dietary Health (Google Sheets CSV): Uniquely, LifeHub tracks "Food Delivery Spending" by parsing a CSV from Google Sheets. It tracks your spending trends and calculates a "Clean Streak"—the number of days since you last ordered takeout.
The "Manual Refresh" Philosophy
Unlike apps that drain battery in the background, LifeHub relies on intentionality.
* Incremental Refresh: Updates the last 7 days of data.
* Comprehensive Refresh: Rebuilds history from January 1, 2023.
When a refresh is triggered, the app compiles a `dashboard_data.json` payload containing calculated metrics (e.g., "Sleep Consistency: 1.2h deviation") and raw chart data. This payload is securely uploaded to a GitHub Gist using a Personal Access Token stored in the iOS Keychain.
Part 2: The Analog Dashboard (Raspberry Pi)
The physical manifestation of LifeHub is a Raspberry Pi Zero 2 W connected to a Waveshare 7.5" E-Ink Display and powered by a PiSugar 3 Battery HAT.
The "Fat Python, Skinny HTML" Approach
Rendering complex layouts on E-Ink displays is notoriously difficult using standard drawing libraries. LifeHub circumvents this by using web technologies:
1. Flask Server: The Pi spins up a local web server to render a localized HTML/CSS page using Tailwind CSS.
2. Selenium & Chromium: A headless browser captures a pixel-perfect 800x480 screenshot of that local web page.
3. Image Processing: The screenshot is converted to a 1-bit bitmap and pushed to the E-Ink screen.
The Run-and-Sleep Cycle
To run efficiently on battery, the system utilizes the PiSugar's RTC (Real Time Clock). The operating lifecycle is controlled by a robust shell script (`run_and_sleep.sh`):
1. Wake: The PiSugar wakes the Pi at a scheduled time (e.g., 7:00 AM).
2. Update: The script pulls the latest code from GitHub, fetches the JSON data from your Gist, and renders the screen.
3. Safety Checks: Before shutting down, it checks for a `STOP` file. If present (useful for debugging), it stays awake.
4. Sleep: If safe, it schedules the next alarm and shuts down the hardware completely.
Building LifeHub
Building this ecosystem requires setting up the iOS "sender" and the Raspberry Pi "receiver."
Phase 1: The iOS App
Prerequisites: Mac with Xcode 15+, iPhone (iOS 17+).
1. Configure Data Sources: Grant the app HealthKit permissions (Steps, Energy, Sleep, Weight). Set up a Google Sheet for food orders, publish it as a CSV, and add the URL to `DataModelActor.swift`.
2. Set Up the Bridge: Create a GitHub Personal Access Token (Gist scope only). Input this token into the app's Settings menu.
3. Deploy: Build the app to your phone and run a "Comprehensive Refresh." Verify that a `dashboard_data.json` file appears in your GitHub Gists.
Phase 2: The Hardware (Raspberry Pi)
Prerequisites: Pi Zero 2 W, Waveshare 7.5" V2 Display, PiSugar 3.
1. System Prep: Install Raspberry Pi OS Lite (Headless). Increase Swap Memory to 1024MB (required for Chromium to run on a Pi Zero). Enable SPI via `raspi-config`.
2. Environment Setup: Clone the LifeHub repository. Create a Python virtual environment and install dependencies (`requirements.txt`). Install the Waveshare e-Paper drivers.
3. Configuration: Edit `config.py` with your Gist's Raw URL. Optionally add a Google Cloud Service Account JSON for telemetry logging to Google Sheets.
4. Automation: Add the `run_and_sleep.sh` script to your crontab: `@reboot /path/to/script`.
Operations & Safety
The system includes built-in safeguards for development. If you need to SSH into the Pi without it shutting down automatically:
* Panic Button: Triggering a specific command or button press creates a `STOP` file.
* Aliases: The system uses aliases like `stop` (to prevent shutdown) and `go` (to resume automation) for easy management.
Conclusion
LifeHub transforms the Raspberry Pi from a tinkering toy into a polished lifestyle appliance. By offloading the heavy data processing to the iPhone and using the Pi strictly for retrieval and rendering, it achieves a balance of high-fidelity data visualization and low-power durability. It is a personalized, always-on reflection of your health, finance, and habits.