A comprehensive supply management integration for Home Assistant. Track your emergency food stocks, monitor expiration dates, and calculate total available calories - all within your Home Assistant dashboard.
- 📦 Complete Inventory Management - Add, edit, and remove items with detailed information (name, brand, weight, calories, expiration date)
- 🔍 Smart Search & Filtering - Quickly find items by name, brand, or filter by category
- 📊 Real-time Calorie Tracking - Automatic calculation of total available calories based on quantities
- 📅 Expiration Date Monitoring - Keep track of expiration dates for all your supplies
- 🏷️ Category Organization - Organize items into 13 collapsible categories
- ✏️ Edit Products - Change name and category of existing items
- 💾 Persistent Storage - All data is automatically saved and persists across restarts
- 🎨 Beautiful Custom Card - Modern, responsive Lovelace card with intuitive UI
- 📷 Barcode Scanner - Scan product barcodes with your phone camera to quickly add items using Open Food Facts database
- 🌐 Multi-language Support - Fully translated into English and Polish
Items can be organized into the following categories:
- 🍜 Instant foods
- 🌾 Dry goods
- 🍫 Sweets
- 🍱 Ready meals
- 🥫 Canned foods
- 🫙 Preserves
- 🍅 Tomatoes
- 🧂 Spices
- 💊 Medications
- ⚡ Energy foods
- 🥤 Beverages (Napoje)
- 🍷 Alcohol (Alkohol)
- 📦 Other
- Make sure you have HACS installed
- Open HACS → Integrations
- Click the three dots menu (⋮) in the top right
- Select "Custom repositories"
- Add this repository:
- URL:
https://github.com/banzamel/apocalypse-stock - Category: Integration
- URL:
- Click "Add"
- Find "Apocalypse Stock" in the integration list and click "Download"
- Restart Home Assistant
- Go to Settings → Devices & Services → Add Integration
- Search for "Apocalypse Stock" and add it
- Download the latest release
- Extract the
apocalypse_stockfolder - Copy it to your Home Assistant's
custom_componentsdirectory:/config/custom_components/apocalypse_stock/ - Restart Home Assistant
- Add the integration via UI (Settings → Devices & Services)
- Navigate to Settings → Devices & Services
- Click "+ Add Integration"
- Search for "Apocalypse Stock"
- Click to add the integration
- The sensor
sensor.apocalypse_stock_datawill be created automatically
The custom card is automatically registered. Add it to your dashboard:
- Edit your dashboard
- Click "Add Card"
- Scroll down or search for "Apocalypse Stock Card"
- Click to add
type: custom:apocalypse-stock-card- Click the "+ DODAJ" (Add) button in the card
- Fill in the item details:
- Category: Select from dropdown
- Product name: e.g., "Rice"
- Brand: e.g., "Uncle Ben's"
- Weight: Weight in grams
- Expiration date: Select from calendar
- Calories: Calories per unit
- Click "ZAPISZ" (Save)
- Click "+ DODAJ" to open the add item modal
- Click "📷" to scan or type the barcode manually in the input field and click "🔍"
- Point your phone camera at the barcode — position it inside the red guide frame
- The scanner detects the barcode using BarcodeDetector (native API or ZXing WASM polyfill) and validates the checksum
- For 13-digit EAN codes, the form will be automatically filled with product data from Open Food Facts:
- Product name and brand
- Weight in grams
- Calories (calculated per unit based on kcal/100g)
- Auto-mapped category
- Review and adjust the data, then click "ZAPISZ" (Save)
Note: Barcode scanning uses the native BarcodeDetector API (Chrome/Android) with automatic ZXing WASM fallback for other browsers. Use the torch button for better illumination if needed.
- Adjust Quantity: Use + / - buttons next to each item
- Delete Item: Click the ✕ button
- Search: Type in the search box to filter by name or brand
- Filter by Category: Use the dropdown to show only specific categories
- Expand/Collapse: Click category headers to show/hide items
- Total Calories: Displayed in the header (e.g., "(25,000 kcal)")
- Category Counts: Shows number of items in each category badge
- Item Details: Each item shows name, brand, weight, calories, expiry date
- Auto-expand: Categories automatically expand when searching
- Sensor:
sensor.apocalypse_stock_data- State: Total number of items
- Attributes: Array of all items with details
- Service:
apocalypse_stock.update_stock- Updates the stock data (called automatically by the card)
- Data stored in:
.storage/apocalypse_stock.storage - Automatically saved on every change
- Survives restarts and updates
custom_components/apocalypse_stock/
├── __init__.py # Integration setup
├── config_flow.py # Configuration flow
├── manifest.json # Integration metadata
├── sensor.py # Sensor entity
├── translations/
│ ├── en.json # English translations
│ └── pl.json # Polish translations
└── www/
└── apocalypse-card.js # Custom Lovelace card
The card automatically adapts to your Home Assistant theme, using CSS variables:
--primary-color--accent-color--card-background-color--primary-text-color--secondary-text-color--divider-color
- Check browser console for errors (F12)
- Clear browser cache (Ctrl+Shift+R)
- Verify the integration is installed correctly
- Restart Home Assistant
- Check Home Assistant logs for errors
- Verify write permissions in
.storage/directory - Check that the sensor entity exists
- The card updates automatically when the modal is closed
- Check browser console for JavaScript errors
- Try refreshing the page
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Clone the repository
git clone https://github.com/banzamel/apocalypse-stock.git
# Create a symlink to your Home Assistant config
ln -s $(pwd)/custom_components/apocalypse_stock /path/to/homeassistant/custom_components/
# Restart Home Assistant- Alphabetical sorting of products within categories
- Added new categories: Napoje (Beverages) and Alkohol (Alcohol)
- Fixed category selection bug — internal values now match display names (Owoce → Instant)
- Added product editing — change name and category of existing items via edit button
- Auto-mapping for new categories from Open Food Facts data
- Replaced Tesseract.js OCR with BarcodeDetector library (native API + ZXing WASM polyfill)
- Proper barcode scanning from camera instead of OCR digit recognition
- Supports EAN-13, EAN-8, UPC-A, Code 128 formats
- Barcode checksum validation after each read
- API product lookup restricted to 13-digit EAN codes only
- Faster scan loop (250ms vs 800ms) thanks to native barcode detection
- Double-read confirmation still active for reliable scanning
- Replaced BarcodeDetector with OCR digit recognition (Tesseract.js)
- Reads 13-digit EAN code from numbers printed below barcode
- Visual guide frame showing where to position the barcode digits
- Image preprocessing (grayscale + high contrast) for better OCR accuracy
- Double-read confirmation (same code recognized 2x) before accepting
- Camera and OCR engine load in parallel for faster startup
- Works in all browsers and WebViews (no native API dependency)
- Rewritten camera scanner — single stream with applyConstraints for native max resolution
- Fixed camera showing snowy/low-quality image (was reopening stream with lost deviceId)
- Fixed scanner not closing (robust cleanup with try-catch on every step)
- Canvas-based barcode detection at native resolution instead of scaled video element
- Added
object-fit: containto prevent image distortion/zoom - Shows actual camera resolution in scanner overlay for debugging
- Torch button with proper on/off toggle state
- Fixed low camera resolution in WebView — two-step stream init to request max resolution
- Improved camera autofocus for barcode scanning (close-range focus distance)
- Added tap-to-focus — tap the camera preview to re-trigger autofocus
- Added torch/flashlight button for better barcode illumination
- Added double-read confirmation to eliminate false barcode reads from blurry frames
- Fixed camera preview not showing in WebView (Android companion app)
- Replaced barcode scanner with native BarcodeDetector API for accurate reads
- Removed html5-qrcode (ZXing-js) library — fixed incorrect barcode values
- Added barcode checksum validation (EAN-13, EAN-8, UPC-A)
- iOS: camera scanning not supported, use manual barcode input
- Added manual barcode input field with search button
- Improved barcode scanner accuracy and reliability
- Fixed UPC-A to EAN-13 conversion for barcode lookup
- Enabled continuous autofocus for barcode scanner camera
- Barcode scanner with html5-qrcode library
- Open Food Facts API integration for automatic product lookup
- Auto-category mapping from product data
- Initial public release
- Full inventory management
- Category organization
- Search and filtering
- Calorie tracking
- Persistent storage
- English and Polish translations
This project is licensed under the MIT License - see the LICENSE file for details.
- Built for the Home Assistant community
- Inspired by the need for better emergency preparedness tracking
- Thanks to all contributors and testers
- 🐛 Bug Reports: GitHub Issues
- 💡 Feature Requests: GitHub Issues
- 💬 Discussions: GitHub Discussions
- ⭐ Show Support: Star this repository!
Made with ❤️ for the Home Assistant community
Note: This integration is not affiliated with or endorsed by Home Assistant. It's a community project.