Skip to content

Sensor integration for Pantry Tracker to integrate data with HomeAssistant

License

Notifications You must be signed in to change notification settings

mintcreg/pantry_tracker_sensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pantry Tracker - Custom Components

Pantry Tracker Card Logo

Caution

This is a work in progress and made using GPT and basic knowledge.

Description

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.


Features

  • 🖥️ 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.


Requirements

  1. Pantry Tracker Add-on
    The Pantry Tracker Add-on 1.0.51 (onward) must be installed and running.

Installation

  1. Add https://github.com/mintcreg/pantry_tracker_sensor to HACS

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

  1. Install from HACS

  2. Add the below to config.yaml

    sensor:
      - platform: pantry_tracker
        scan_interval: 30  # (Optional) defaults to 30 if not defined
  3. Restart HomeAssistant

Alternatively

  1. Download and Install Copy the pantry_tracker folder to the custom_components directory in your Home Assistant configuration.

  2. Add the below to config.yaml

    sensor:
      - platform: pantry_tracker
        scan_interval: 30  # (Optional) defaults to 30 if not defined

Usage

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

Demo

Categories

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

Services

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.

Service Call Examples

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

About

Sensor integration for Pantry Tracker to integrate data with HomeAssistant

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages