banner
Leo

Leo的恒河沙

一个活跃于在珠三角和长三角的商业顾问/跨境电商专家/投资人/技术宅/骑行爱好者/两条边牧及一堆小野猫的王/已婚;欢迎订阅,日常更新经过我筛选的适合精读的文章,横跨商业经济情感技术等板块,总之就是我感兴趣的一切

2023-10-25-Planning Inventory, Reducing Waste: An Item Management Solution Based on Grocy - Minority

Planning Inventory, Reducing Waste: An Item Management Solution Using Grocy as a Database - Minority#

#Omnivore

Planning Inventory, Reducing Waste: An Item Management Solution Using Grocy as a Database

Introduction#

In our household, there are two of us, and we have a habit of stockpiling. We believe we have relatively good storage habits in our lives, but we sometimes feel ashamed of expired items lying deep in the cupboard or of having purchased excessive quantities of items. To address this, the lady of the house took the initiative to inventory our stock and digitize the entries, later managing it with an app called "Expired." A year later, with a big sale approaching and stockpiling in mind, I asked my wife, "Are you still using 'Expired'?" "No, it's a bit troublesome, and I always forget to record."

Before delving deeper, we seriously considered whether managing inventory at home was "over-management." Ultimately, we recognized the value of household inventory management:

  • To have a clear understanding of the household stock;
  • To plan the use of items and effectively reduce waste;
  • To satisfy those with hoarding tendencies. But this comes with the premise that there are enough items and a high level of automation.

Storage Apps, Stopped by Laziness#

I began searching online for like-minded individuals. I found that many have already practiced this; some use storage apps to record, while others use Notion or TickTick to manage.

image

Sorter, Expired, Food Rescue

image

Notion Template "Inventory Tracking"

These apps are beautifully designed, feature-rich, and even have many extended functionalities, such as shopping records, price tracking, recipe planning, etc. We have also subscribed to some apps for in-depth use, but after a while, we gave up.

The subjective factor is laziness. However, we found that these applications/services have an objective flaw: difficulty in inventory management.

In the simplest process, completing an item's outflow requires "picking up the phone - unlocking the phone - finding and opening the app - scanning the item"; while inflow is even more cumbersome, requiring additional settings for "quantity," "expiration date," and "storage location." More realistically, in family life scenarios, the phone is not always at hand. For example: while showering, realizing the soap is finished, going to the bathroom cabinet to grab one; while cooking, noticing the cooking oil is finished, rushing to the pantry to grab a bottle. Once you fail to record the item in/out at that moment, it becomes hard to remember to do so later, and the inventory numbers become unreliable. As one netizen commented:

What you need is a Jarvis that monitors you 24/7, not an app like this. You’ll realize after recording less than five entries that, oh, it’s easier to just remember it. The driving force of human evolution is laziness...

If you have used other storage apps, you should understand that the hardest part is sticking to item entry.

Based on previous failures, we summarized the core functionalities we needed:

  • Quick and automatic item in/out management;
  • Automatic recognition and classification of item information;
  • Expiration and low stock reminders;
  • Automatic replenishment lists;

Any additional features are just icing on the cake. The core functionalities we crave are not just a touch-and-go but need to be as automated as possible. To achieve personalized needs, we can only do it ourselves or seek help from the open-source community, which is how I found Grocy.

ERP beyond your fri...

ERP beyond your fridge - Groc...

image

Grocy is an open-source grocery management solution for households. Its main features include:

  • Item in/out management via barcode interaction, supporting mobile phones or dedicated barcode scanners;
  • Recipe and meal planning, managing your own recipes and scheduling meals in a calendar;
  • Expiration reminders for items;
  • Shopping lists automatically generated from recipes;
  • Device, household chores, and power management.

image

Grocy - Desktop

image

Grocy - Android

Overall, Grocy provides a great framework with an easy-to-use API. It also has a relatively active community. Currently, there are iOS clients, Android clients, Barcode Buddy scanning assistants, Home Assistant plugins, Recipe Buddy recipe assistants, etc. Grocy already has features like barcode in/out management and food information retrieval based on Open Food Facts, but its interaction, like other apps, still strongly relies on mobile phones, depending on manual entry; it cannot recognize domestic products; and the in/out management is not sufficiently "automated."

Filling the Gaps, GrocyCompanionCN#

image

GrocyCompanionCN

Grocy already has basic functionalities, and to enhance Grocy's level of "automation" and solve the difficulties of item in/out management, I designed a set of auxiliary tools—GrocyCompanionCN, which includes a software server and hardware scanner. The server is responsible for obtaining and parsing basic item information and communicating with Grocy; the client consists of several scanners that obtain the EAN barcode of items and send the barcode information, location information, and in/out settings to the server.

image

GrocyCompanionCN Hardware and Software

The features of GrocyCompanionCN include:

  • Quick barcode recognition, supporting domestic and imported products;
  • Grocy item barcode outflow;
  • Scanning existing items into Grocy, automatically retrieving product details for new items; (Product details include: barcode, basic information, images, GPC category, expiration date determination, etc.)
  • Automatic start/stop of the scanner, long battery life.

The core of enhancing user experience is the scanner, which can be handheld or placed anywhere in the home (corresponding to "locations" in Grocy), powered by batteries or cables. Here are a few application scenarios.

Scanners installed inside cabinets. Similar to many strip lights in wardrobes: the scanner is triggered to turn on/off by a limit switch; a toggle switch can set it to outflow (default)/inflow; there will be a buzzer and indicator light prompt when scanning is successful; the item information obtained by the scanner will automatically sync with Grocy.

image

Scanner installed in the living room cabinet

image

Scanner installed in the bathroom cabinet

The scanner can be removed from the base and used handheld for bulk item inflow.

image

Widely distributed scanners in storage spaces allow us to avoid manually clicking any screens; item in/out can be completed in seconds. We no longer have to subjectively "stick" to the entry work; all operations are completed effortlessly.

Technical Implementation of GrocyCompanionCN#

I have hosted the source code of GrocyCompanionCN on GitHub and provided a Docker image. For specific deployment methods, please visit:

Below are the implementation ideas and technical details of GrocyCompanionCN.

Item Identity Association#

After reviewing the technologies of existing major supermarkets and vending machines, there are several methods to achieve item information networking:

  • Scanning item barcodes to check pre-entered information. Common in major supermarkets;
  • Using RFID to archive labels, with RFID tags attached or embedded in items, retrieving items via RFID, common in flower vending machines and self-checkout baskets;
  • Machine vision, identifying user-picked items through visual analysis of product features, common in beverage vending machines.

image

Self-checkout machines and vending machines

Considering system robustness, cost, implementation difficulty, and product databases, we chose barcodes to complete item identity association. Any legitimately sold product should have a barcode, and it is unique, with the commonly used code being EAN.

EAN (European Article Number) is a product barcode promoted globally by the International Article Numbering Association. EAN13 is its standard version, consisting of 13 digits, while there is a shortened version EAN8, consisting of 8 digits. EAN13 is an internationally recognized symbol system, a meaningless, fixed-length, purely numeric barcode primarily used for product identification, with uniqueness. The 13 digits of EAN13 consist of a 3-digit country code (China's available country codes are 690-699); 4-7 digits for the manufacturer code (allocated from a pool of 10,000 numbers, 0000 - 9999); 8-12 digits for the product code (each manufacturer can allocate codes for up to 100,000 products); and the last digit is a check digit.

image

Structure of EAN-13 barcode

At the same time, we also have free channels to obtain item information corresponding to barcodes. The China Article Numbering Center provides barcode queries (with a daily query limit).

China Article Numbering Center. As of now, the coding center has provided barcode services to over one million enterprises, with over one billion products nationwide bearing barcodes. On its provided China Product Information Service Platform, we can query barcode-related information.

Item Classification and Expiration Settings#

Analyzing the barcode information obtained from the China Article Numbering Center, I found a "GPC" attribute that can help us solve the item classification problem. According to the GPC classification code version released on May 6, 2023, there are a total of 43 major categories, 159 middle categories, 932 small categories, and 5249 detailed categories.

GPC Classification Code is a code that classifies similar products into categories based on the GPC standard by the Global Standards 1 Organization (GS1). The GPC classification code is continuously expanded and updated, with two new versions released each year. The GPC classification code is divided into major categories (Segment), middle categories (Family), small categories (Class), and detailed categories (Brick), and further subdivided into specific core attribute types and attribute values. In product data exchange, the 4th level code, i.e., detailed category code, is usually used.

Barcodes can only tell us the registered information of products and rarely provide expiration date information. Therefore, I observed the expiration dates of common items in life and flexibly used four types of GPC classification codes to pre-set the expiration dates for new items. Additionally, I set some offsets: six months (-30 days), one year (-60 days), three years (-90 days), thus allowing for a rough match of item expiration dates. Of course, precise settings for products can still be made in Grocy later.

This mechanism is particularly crucial, as it can completely liberate us from the tedious task of calculating expiration dates one by one when entering items. Readers can also set categories and offsets based on their actual situations.

Expiration (days)Category
750370000 (middle category, fresh-cut fruits or vegetables), 50380000 (middle category, fresh-cut fruits or vegetables), 50350000 (middle category, unprocessed or unprocessed (fresh) leafy vegetables)
1450250000 (middle category, unprocessed or unprocessed (fresh) fruits), 10000025 (detailed category, milk (perishable)), 10006970 (detailed category, milk substitutes (perishable)), 10000278 (detailed category, yogurt (perishable)), 10006979 (detailed category, yogurt substitutes (perishable))
15250270000 (middle category, unprocessed or unprocessed frozen fruits), 50310000 (middle category, unprocessed or unprocessed durable fruits)
30594000000 (middle category, grain crops), 50000000 (major category, food, beverages, and tobacco), 10120000 (middle category, pet care products or food combo), 10110000 (middle category, pet food or drinks)
100553000000 (major category, beauty, personal care, and hygiene products), 47100000 (middle category, cleaning products), 47190000 (middle category, cleaning and hygiene product combos), 51000000 (major category, healthcare), 10100000 (middle category, pet care products)

Scanner Hardware#

Why not use ready-made barcode guns?

  • They are bulky and cannot be embedded in cabinets, making it impossible to escape the operation mode of holding an item in one hand and the machine in the other;
  • They are costly, with typical wireless barcode scanners priced around 180 yuan, and wireless barcode/QR code scanners priced around 280 yuan;
  • They cannot switch between outflow/inflow;

image

The homemade scanner features a small size, low power consumption, low cost, and strong compatibility. It can recognize EAN codes, UPC codes, QR codes, ISBN codes, etc. Therefore, while fulfilling existing functionalities, it can also be used in the future to recognize and input manufacturers' private codes and books. The modules used in the scanner include:

  • Scanning module GM805
  • ESP01
  • AMS1117
  • Limit switch
  • 3.7V, 600mAh lithium battery

The scanning module GM805 comes with a buzzer and light, while the ESP01 is responsible for uploading the barcode data obtained by GM805 to the server. The limit switch triggers the power on/off, achieving ultra-long battery life; a toggle switch can set it to outflow (default)/inflow. Below is a schematic diagram of the hardware wiring.

image

Wiring diagram

Regarding automatic start/stop and battery life. The working current of GM805 is <70mA, and the sleep current is about 6mA. Therefore, even if the sleep current of ESP8266 can reach microamp levels, 600mAh cannot keep the scanner in standby for more than a week. Thus, using a limit switch to trigger power on/off can effectively avoid power loss during idle times. In my tests, 600mAh can keep the scanner working continuously for about 3.5 hours. Based on our habits, it is expected to last over 4 weeks without issues.

Regarding startup speed. Without any optimization, the scanner can enter working status within 3 seconds, mainly limited by the networking speed of ESP8266. If a static IP is set, the initialization speed can be greatly improved.

Boot, connect to wifi, server requests in under 1 second with ESP-01

, it can complete startup within 1-2 seconds.

Server#

The server deploys a simple backend responsible for processing data uploaded by the scanner, fetching barcode information externally, and communicating with Grocy. The raw data fetched externally will be stored in Grocy's GDSInfo parameter for future upgrades and customizations; it can also automatically complete the cropping of product images; for international products not included in the China Article Numbering Center (without domestic agents), it scrapes BarcodeLookup to complete information supplementation.

image

Automatic image cropping of products

GDSInfo#

By adding a custom attribute "GDSInfo" in the product properties through "custom items," the raw product data obtained by GrocyCompanionCN is stored in the GGDSInfo parameter for future functional upgrades.

Parent Products#

Parent products can accumulate the total number of their child products and set a total safety stock. For example, we set a parent product "Tissue." "Tissue" contains 3 child products, with a total safety stock of "3." When the total number of "Tissue" is less than or equal to 3, Grocy will automatically add it to the shopping list, prompting us to restock. This way, we don't have to worry about setting safety stocks for each child product. The automatic classification of child products can be determined through GPC codes and product keywords.

image

Product grouping and automatic shopping list

API and Automation#

Grocy provides an easy-to-use REST API, allowing us to conveniently extend functionalities and streamline data flow. For example, sending restock reminders via Gotify; sending shopping lists to to-do lists; broadcasting reminders for household chores through smart speakers, etc.

Grocy Barcodes#

Grocy generates a unique barcode for each entity. When the item packaging is removed, the barcode is lost, or the product is a gift, sample, or trial pack (without an EAN code), we can create a barcode for such items using a label printer.

image

Conclusion#

Unlike previous methods of managing inventory solely through mobile phones and software, we designed a very simple piece of hardware to help us break down the barrier between data and the real world, liberating the user from the role of "intermediary."

This solution uses Grocy as a database for item management, but with simple modifications, we can also automate data synchronization to Notion or multidimensional tables like Airtable. This provides diverse visualization options.

Finally, I wish everyone a pleasant stockpiling experience during Double Eleven.

Follow Minority WeChat Official Account to unlock a new reading experience 📰

Practical and useful genuine software, presented to you by Minority 🚀

  • 1 My inventory management solution 2.0, starting with a toothbrush
  • 2 Grocy plugins
  • 3 GPC classification code definitions
  • 4 GPC classification code queries
  • 5 Boot, connect to wifi, server requests in under 1 second with ESP-01

© This article is copyrighted by the author and authorized for exclusive use by Minority. Unauthorized reproduction or use without permission from Minority is prohibited.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.