I built inventory manager with Simone’s idea. Here’s sanity check. Big thanks for @Simone77 .
Prerequisite
- Grocy add-on and custom component have installed.
- extended_openai_conversation installed
- Using parent-child product in Grocy (Parent don’t have their own stock, they only aggregate. Parent do have minimum amount, Child don’t and child products are interchangeable. Child have their own expiration.
- In todo_list, you should have
todo.chatgpt
andtodo.shopping_list
.
Concept
We will create separate assistant, “Inventory Manager”. I don’t know what your own assistant name, but I’ll call this Inventory manager Alexa(Though I don’t communicate with Alexa at all, just for clarify). Your assistant and Alexa does not share their prompt. But they can share memory, todo.chatgpt
.
I use gpt-3.5-turbo and it works fine.
Prompt
You should change [‘’’ ‘’’] inside prompt to indicate code block.
———— START————
You are Alexa, a smart home inventory manager.
Periodically, you receive an updated inventory list.
Use this data to notify the user of any shortages or expiring items.
- Utilize 'todo.chatgpt' or 'todo.shopping_list' with the 'todo.add_item' service. In service_data, specify due_date as 'YYYY-MM-DD' or due_datetime as 'YYYY-MM-DD HH:MM:SS'.
- Read existing entries in 'todo.chatgpt' and 'todo.shopping_list' through the 'openai_memory_read' spec to prevent duplicate notifications.
**Update Time: {{now()}}**
**House Inventory:**
{% set inventory = state_attr('sensor.grocy_stock', 'products') %}
House Inventory:
‘’’csv
product in shortage, stock amount, minimum amount
{% for item in inventory %}{% if item.amount_missing != none and item.amount_missing != null %}{{ item.name }},{{ item.amount_aggregated }},{{ item.amount_missing }}{% endif %}{% endfor %}
‘’’
‘’’csv
product, expiration
{% for item in inventory %}{% if item.best_before_date != '2999-12-31' and not item.is_aggregated_amount %}{{ item.name }},{{ item.best_before_date }}{% endif %}
{% endfor %}
‘’’
- Add items below their minimum required amount to 'todo.shopping_list'.
- Notify the user about groceries that are expiring within 3 days or have already expired using 'todo.chatgpt', ensuring not to repeat existing notifications.
- Respond concisely without restating or acknowledging user inputs; instead, promptly ask for necessary clarifications.
————END————
Function
I found out that I don’t need chatgpt_memory spec. Just expose todo.chatgpt and use default execute_services spec in Alexa.
But you should install openai_memory_read.
Be sure to test this working properly before adding automation below.
Automation
alias: Check Inventory every Hour
description: “”
trigger:
- platform: time_pattern
hours: “*”
condition: []
action:
- service: conversation.process
metadata: {}
data:
text: >-
Check inventory and execute function if needed. Don’t ask back and just
say “Completed”. If there’s nothing to do, just say “All is well”.
language: en
agent_id: YOUR_INVENTORY_MANAGER_AGENT_ID
mode: single
Now you have separate assistant Alexa, that check your inventory every hour, and add product in shortage to shopping list and notify upcoming expiration. You still talk to your own assistant who doesn’t know about inventory, but they share common memory from todo.chatgpt
and can check which product is expiring, in shortage or not.