Hayden Griffin

Food Diary

A calorie and macro diary that runs in Home Assistant, with a native SwiftUI iPhone app, Apple Health sync, and planned meals that go straight into the diary.

A calorie and macro diary that lives in your own Home Assistant, with a native iPhone app that makes logging a meal a photo, a barcode or a sentence.

Most food trackers keep your diary on someone else's server. This one stores every food, goal and saved meal in Home Assistant, with sensors you can chart and automate on. The iPhone app is a fast front end to it, with no account and no data of its own.

What's in the repo

Path What it is
custom_components/food_diary The Home Assistant integration: the diary, goals, sensors, 24 services, a webhook and voice intents. Installable through HACS.
ios/ Food, the SwiftUI iPhone app, with widgets, Control Center controls, a share extension and two-way Apple Health sync.
custom_sentences/ Optional Assist sentences: "log two eggs on toast for breakfast", "how many calories have I got left?"
docs/integration.md The full reference: options, entities, every service with its fields and responses, and the sensor contracts, and the interface for another integration to provide recipes and a meal plan.

The app

Adding food: five ways in, checking several foods at once, and editing an entry

Looking back: the week in review, a month calendar with activity rings, and the streak sprig

The Home Screen widget with calories left and one-tap usuals

The full feature list, build steps and signing notes are in ios/README.md.

How it works

Architecture: the iPhone app talks to the food_diary integration over REST; Home Assistant uses AI Task and Open Food Facts; the app syncs with Apple Health

Getting started

  1. Install the integration. In HACS, add https://github.com/HaydenGriffin/ha-food-diary as a custom repository (category Integration), install Food Diary and restart. Or copy custom_components/food_diary into your config folder.
  2. Add a diary. Settings → Devices & services → Add integration → Food Diary, once per person. Setting up an AI Task entity first gives you photo, label and text logging.
  3. Build the app from ios/ with your own Apple developer team, then sign in to your Home Assistant.
  4. Optional: copy custom_sentences/en/food_diary.yaml into your config for voice logging, and connect a meal plan sensor (contract).

You don't need the app to use the diary: every feature is a service, so dashboards, automations and Assist can drive it too.

Development

# Integration
python -m venv .venv && source .venv/bin/activate
pip install -r requirements_test.txt
pytest

# App (see ios/README.md for signing)
cd ios && cp Config/Local.xcconfig.example Config/Local.xcconfig && xcodegen && open Food.xcodeproj

The UI tests run against a mock Home Assistant (ios/tools/mock_ha.py) with demo data. The images above are rendered from those tests' screenshots by tools/showcase.

Background

I built this for my own household: a replacement for a subscription food tracker that keeps our data at home and fits into the rest of our Home Assistant setup. This is the public cut of it, with the house-specific parts removed.

Support

Food Diary is free and open source. If it made keeping your diary easier, you can buy me a coffee. Bug reports and pull requests are just as welcome.

License

MIT