If you found this useful, please star this repo.
An ESPHome configuration for an ESP32-CAM tailored for monitoring a refrigerator interior. Includes video streaming, a toggleable flashlight, and a reed-switch door sensor.
You can mount it inside or outside the fridge, but... Just do it how you want...
- Camera: AI Thinker ESP32-CAM module.
- Flashlight: Built-in high-power LED connected to
GPIO4. - Door Sensor: Simple 2-wire magnetic reed switch connected between
GPIO13andGND(no external resistors needed due toINPUT_PULLUP).
- Copy the contents of
esphome-config.yamlinto your ESPHome environment. - Edit the top
substitutions:block to match your preferred names and area. - Ensure your local
secrets.yamlcontains the required keys:wifi_ssid,wifi_password, andfridgecam_api_key. - Flash the device.
- Home Assistant AI Automation Setup
This blueprint takes a snapshot when the door opens, sends it to an AI vision model, and creates or updates one To-Do item per recognized food item: name plus separate quantity, condition, confidence and note fields, and an estimated bounding box (for fridge-card's detection-frame overlay). Items already in the list are matched by name, so an expiration/"best before" date you set by hand stays intact across scans. So does anything you edit on the card: quantity, condition, note, a Brand (which the AI never writes to at all) and a detection frame you drew by hand all stay exactly as you set them on the next scan instead of being overwritten by a fresh AI guess. Confidence is always the AI's latest estimate, since only the AI ever sets it. Items no longer detected are left alone - remove them yourself once you've used them up. An item marked eaten on the card is reactivated - not duplicated - if a later scan still recognizes it under the same name; it was evidently still there.
The AI is also told which item names were already used in a previous scan (with their last known box location) and asked to reuse an exact name when it's plausibly the same physical item — e.g. if you rename "Palacinka" to "Praženica" on the card, the next scan is nudged to say "Praženica" again instead of re-guessing. This is not real training — each analysis is a fresh, stateless request with no memory of past runs — it's just context added to that one prompt, so it's a best-effort nudge, not a guarantee; the AI can still occasionally invent a different name.
The AI Output Language blueprint input switches the item names/descriptions between English and Slovenčina; the structural markup (confidence scores, box coordinates) is unaffected.
Two delays are also configurable as blueprint inputs: Snapshot Delay (how long to wait after turning on the light before taking the photo, default 2.435s, to let the fridge interior get fully lit) and AI Analyze Delay (how long to wait after taking the photo before sending it to the AI, default 0s).
The Enable AI Detection toggle (on by default) lets you turn off the AI analysis and To-Do list update without disabling the automation itself: with it off, the door still triggers a snapshot and the light still cycles, but no AI request is made and the To-Do list is left untouched.
- AI Integration: You must have an extended AI conversation or task integration configured (like
Google Generative AIorOpenAI Conversation) that provides theai_task.generate_dataaction. - Folder Creation: Ensure the folder
/config/www/fridge/exists in your Home Assistant configuration directory to allow the camera snapshot to save correctly. - To-Do List: Create a dedicated To-Do list in Home Assistant named
Fridge Contents(or similar).
Click the button below or copy your raw file link directly into the Settings > Automations & Scenes > Blueprints > Import Blueprint menu in Home Assistant.
fridge-card's Save and ◀ ▶ Latest controls let you keep a copy of
the current photo and browse back through previously saved ones. This
needs one shell_command added to your Home Assistant
configuration.yaml - the card is just a browser page, so it has no way
to copy a file on the HA server by itself:
shell_command:
fridge_save_snapshot: >-
sh -c 'ts=$(date +%s);
mkdir -p /config/www/fridge/history;
cp /config/www/fridge/fridge_latest.jpg /config/www/fridge/history/fridge_$ts.jpg;
echo $ts >> /config/www/fridge/history/manifest.txt'Restart Home Assistant (or reload YAML) after adding it, then set the
card's snapshot_service option to shell_command.fridge_save_snapshot.
Pressing Save copies whatever fridge_latest.jpg currently holds -
not a fresh camera capture - into history/ under a timestamped
filename, and appends that timestamp to history/manifest.txt; the card
reads that plain text file directly to know what's browsable. Adjust the
paths in the command if your image_path isn't the default
/local/fridge/fridge_latest.jpg. This is entirely optional - without
it, the card just shows the live photo as before.
jan-tdy/fridge-card is the
Lovelace UI half of this project: a custom card that shows the latest
snapshot (with a config option to correct a crooked camera mount, an
optional way to save and browse back through older snapshots - see
above - and a refresh button to force-reload it) and the To-Do items
this blueprint creates as a plain, editable list - name, quantity,
condition, an AI confidence readout, note, brand, expiration date, each
its own field, plus a checkbox to mark an item eaten (tucked into a
collapsed "Eaten" section instead of deleted outright) - an optional
overlay of the bounding boxes this blueprint estimates
(editable/drawable by hand), plus quick controls for the light, door
status, live camera view and re-running this automation. Point its
todo_entity at the same To-Do list configured above.
If you found this useful, please star both repos!