Caution
This is a work in progress and made using GPT and basic knowledge.
The Pantry Tracker Custom Components repository provides a set of Home Assistant integrations to enable seamless interaction between the Pantry Tracker Add-on and Home Assistant. These components allow you to automatically create sensors for pantry categories and products, update their counts in real time, and manage their lifecycle effectively.
-
🖥️ Dynamic Sensor Creation
Automatically creates sensors for each product and category stored in the Pantry Tracker database. -
📊 Real-Time Count Updates
Synchronizes product counts between Home Assistant and the Pantry Tracker Add-on. -
❌ Automatic Cleanup
Removes sensors for products that are deleted from the database to ensure a clean and up-to-date system. -
🔄 Bi-Directional Updates
Supports increasing and decreasing product counts from Home Assistant services.
- Pantry Tracker Add-on
The Pantry Tracker Add-on 1.0.51 (onward) must be installed and running.
-
Install from HACS
-
Add the below to config.yaml
sensor: - platform: pantry_tracker scan_interval: 30 # (Optional) defaults to 30 if not defined
-
Restart HomeAssistant
Alternatively
-
Download and Install Copy the
pantry_tracker
folder to thecustom_components
directory in your Home Assistant configuration. -
Add the below to config.yaml
sensor: - platform: pantry_tracker scan_interval: 30 # (Optional) defaults to 30 if not defined
Auto Entities & Browsermod (No Tracker Card)
type: custom:auto-entities
card:
type: entities
title: Pantry Products
show_header_toggle: false
state_color: true
filter:
include:
- entity_id: sensor.product_*
options:
type: custom:template-entity-row
name: |
{{ state_attr(config.entity, 'product_name') }}
tap_action:
action: fire-dom-event
browser_mod:
service: browser_mod.popup
data:
title: Update Stock
content:
type: vertical-stack
cards:
- type: custom:mushroom-template-card
entity: this.entity_id
primary: |
Product: {{ state_attr(entity, 'product_name') }}
secondary: |
Stock Count: {{ states(entity) }}
icon: mdi:food-apple
layout: vertical
right_button: Add 1 Item
left_button: Remove 1 Item
right_button_action:
service: pantry_tracker.increase_count
data:
entity_id: this.entity_id
amount: 1
left_button_action:
service: pantry_tracker.decrease_count
data:
entity_id: this.entity_id
amount: 1
Tracker Card
Requires the Pantry Tracker Card - https://github.com/mintcreg/pantry_tracker_card
type: custom:pantry-card
entity_prefix: sensor.product
search: true
show_images: true
category_filter: true
The custom component provides the following services to interact with pantry products:
Service | Parameters | Description |
---|---|---|
pantry_tracker.increase_count |
product_name (string) amount (int, optional, default: 1) |
Increase the count of a specific product by its name. |
pantry_tracker.decrease_count |
product_name (string) amount (int, optional, default: 1) |
Decrease the count of a specific product by its name. |
pantry_tracker.barcode_increase |
barcode (string) amount (int, optional, default: 1) |
Increase the count of a product by providing its barcode. |
pantry_tracker.barcode_decrease |
barcode (string) amount (int, optional, default: 1) |
Decrease the count of a product by providing its barcode. |
Increase Count
service: pantry_tracker.increase_count
data:
entity_id: sensor.product_banana
amount: 1
Decrease Count
service: pantry_tracker.decrease_count
data:
entity_id: sensor.product_banana
amount: 1
Barcode Increase
service: pantry_tracker.barcode_increase
data:
barcode: "123456789012"
amount: 3
Barcode Decrease
service: pantry_tracker.barcode_decrease
data:
barcode: "123456789012"
amount: 3