1 Home
Xena Rathon edited this page 2026-06-21 18:28:41 -04:00

Setup & Usage

mealie-grocy-sync reads your Mealie meal plan and adds the ingredients you're missing to your Grocy shopping list. This page covers how to set it up and use it day to day.

How it works (plain English)

  1. Each run it asks Mealie "what's planned for the next few days?"
  2. For each planned recipe it reads the ingredient list ("1¼ cups lentils, 2 cloves garlic…").
  3. For each ingredient it finds the matching Grocy product — and if one doesn't exist yet, a small local LLM (Ollama) gives it a clean name + the right aisle and it's created. It reuses the same matching as the Alexa↔Grocy sync, so you don't end up with two "Garlic" products.
  4. If you already have it in stock, it's skipped. If not, it's added to the Grocy shopping list.
  5. Ubiquitous staples (water, salt, pepper) are ignored via a stoplist.

It's presence-based — "do I have any of this?" — not quantity-aware.

Requirements

  • A running Mealie instance + a long-lived API token (Mealie → Settings → API Tokens).
  • A running Grocy instance + an API key (Grocy → Manage API keys).
  • A local Ollama for ingredient → product naming (any small instruct model, e.g. qwen2.5:7b).
  • Python 3 with requests.

Configuration (environment variables)

Var What it is Default
MEALIE_URL / MEALIE_TOKEN Mealie server URL + API token
GROCY_URL / GROCY_KEY Grocy server URL + API key
OLLAMA_URL / OLLAMA_MODEL Ollama endpoint + model …:11434 / qwen2.5:7b
GROCY_LIST_ID Grocy shopping list id 1
GROCY_LOCATION_ID Default location for newly-created products 3
DAYS_AHEAD How many days of the meal plan to scan 4
MGS_STOPLIST Comma-list of ingredients to never add water,salt,pepper,…
CACHE_FILE Where the resolve cache is kept /app/cache.json
DRY_RUN 1 = log only, write nothing 0

Tip: point MEALIE_URL/GROCY_URL at the LAN address so service-to-service calls bypass any reverse proxy / SSO.

Try it first (preview — writes nothing)

pip install requests
DRY_RUN=1 MEALIE_URL=http://HOST:8082 MEALIE_TOKEN=\
GROCY_URL=http://HOST:9283 GROCY_KEY=OLLAMA_URL=http://HOST:11434 \
python sync.py

You'll see how each ingredient resolves and what would be added.

Deploy (run on a schedule)

sync.py is a one-shot — run it from cron or a tiny container on whatever cadence matches how you plan meals. A common setup is a python:3.12-slim container with the script mounted and an internal scheduler loop, e.g. Mon/Wed/Fri ~8 AM (good for day-at-a-time planners). Set the env vars above; pip install requests on start.

Using it day to day

  • Plan a meal in Mealie — add a recipe to the meal planner for a day. That's the only input.
  • On the next run, the recipe's missing ingredients land on your Grocy shopping list.
  • Already-in-stock items and the stoplist staples are skipped.
  • Plan day-by-day if you like — a few-times-a-week schedule catches your near-term plans.

Gotchas

  • Presence-based: it adds an ingredient if you have none in stock, regardless of how much the recipe needs (quantities are a future v2 feature).
  • New-item matching relies on the local LLM — glance at the products it creates now and then and merge/rename in Grocy if it splits something.
  • Empty meal plan → it's a clean no-op.