Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shopping list quantity is in the wrong units #315

Open
BenBergman opened this issue Nov 24, 2024 · 4 comments
Open

Shopping list quantity is in the wrong units #315

BenBergman opened this issue Nov 24, 2024 · 4 comments

Comments

@BenBergman
Copy link

Unless all relevant information is provided, I can't help you

Describe the bug
When viewing the shopping list in Grocy, the correct units are used for quantity (ie. "Default quantity unit purchase").
image

image

In the shopping list attributes, the unit used is the "Quantity unit stock" (see the 'amount' field).

{'id': 1, 'product_id': 2, 'amount': 60.0, 'note': None, 'product': {'name': 'Nature Clean Natural Dishwasher Pods, 60 count', 'id': 2, 'product_group_id': 2, 'available_amount': 0.0, 'amount_aggregated': None, 'amount_opened': None, 'amount_opened_aggregated': None, 'is_aggregated_amount': None, 'best_before_date': None, 'barcodes': ['058951380207'], 'product_barcodes': [{'barcode': '058951380207'}], 'amount_missing': None, 'is_partly_in_stock': None, 'default_quantity_unit_purchase': {'id': 3, 'name': 'Pack', 'name_plural': 'Packs', 'description': None}}}

When I change the "Quantity unit stock" to match "Default quantity unit purchase", the amount displayed is as I would expect.

Expected behavior
The amount for the shopping list item should match the shopping list in Grocy UI, ie. it should be in the "Default quantity unit purchase" unit, or at the very least have this added as on additional field.

To Reproduce

  1. Create a product in Grocy and use different units for "Quantity unit stock" and "Default quantity unit purchase".
  2. Add the product to your shopping list
  3. Compare the amount in the Grocy UI for the shopping list and the products attribute of sensor.grocy_shopping_list

General information to help debugging:

Core 2024.11.3
Supervisor 2024.11.4
Operating System 13.2
Frontend 20241106.2

Grocy 4.2.0 (installed as add-on)
Grocy custom component 4.11.1

@BenBergman
Copy link
Author

This might be an issue with the Grocy API. Playing with the API explorer, I see the "wrong" amount when I get the shopping list through the API at http://<grocy_ip>:9192/api/objects/shopping_list. I'll dig around the API a bit more and see if the "correct" value is available.

@BenBergman
Copy link
Author

I opened an issue with upstream Grocy as the API seems to be reporting the same incorrect values. This integration has more detailed info in the shopping list attributes so there must be more than just returning the raw API results so I'll leave this as open for now in case it makes sense to patch around it here, but odds are it makes more sense to wait for the upstream fix.

@BenBergman
Copy link
Author

BenBergman commented Nov 24, 2024

From that other ticket it sounds like I misunderstood how the Grocy API works and there is no bug there.

Since this integration seems to be returning more than just the results of a single API call, could a field be added with the amount in the purchase quantity? I had a hard time finding the right place for this when I dug through the code yesterday, but if I find some time I'll try to poke at it a bit myself.

Edit: if adding a "purchase amount" field is undesirable, at least having a field in the product for the stock quantity unit so a conversion can be looked up would be nice.

@BenBergman
Copy link
Author

Digging in a bit, it seems like it is just returning what pygrocy is returning, which it seems is an archived project at this point. Looks like to do my conversions I'll need to do some Grocy REST API calls directly. Sorry for the noise here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant