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

Separate different grocy shopping lists? #21

Closed
anha7196 opened this issue Jun 13, 2023 · 11 comments
Closed

Separate different grocy shopping lists? #21

anha7196 opened this issue Jun 13, 2023 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@anha7196
Copy link

Hi!

Is there a way to separate the items into the different shoppinglists it is possible to create in Grocy with this addon? In my installation i can not see that any of the sensors include witch shopping list the item is on?

I have 8 different lists today, so having all in one in HA makes this pretty much unusable for me.

I hope i have not missed anything obvious and thanks for all the hard work!

/Anders

@Anrolosia
Copy link
Owner

It is an excellent ticket! It will be an enhancement because today there is not distinction between lists. I will work on it and publish an update

@Anrolosia Anrolosia self-assigned this Jun 13, 2023
@Anrolosia Anrolosia added the enhancement New feature or request label Jun 13, 2023
@anha7196
Copy link
Author

Great! Looking forward to it!

@Anrolosia
Copy link
Owner

Hey @anha7196 , I just pushed a new version (0.7.0), with that you should be able to display different shopping lists, and add/remove products to them!
Be carefull, this release includes some breaking changes! You'll have to play with your dashboard a bit :)
Let me know if it's working for you :)

@anha7196
Copy link
Author

anha7196 commented Jun 15, 2023

Hi Anrolosia! That was really quick!
I tried the new version and i saw you documented the changes to the services, looks great!
I could not figure out however if there is any attributes to identify which shopping list an item belongs to. Maybe that is not how you implemented it or do i need do reload data from grocy somehow?

Oh, i just noticed there is an error on the integration page: Retrying setup: can only concatenate str (not "int") to str.
Full error message in logs:

This error originated from a custom integration.

Logger: custom_components.shopping_list_with_grocy
Source: custom_components/shopping_list_with_grocy/apis/shopping_list_with_grocy.py:233
Integration: Shopping List with Grocy (documentation, issues)
First occurred: 14 June 2023 at 21:39:29 (1006 occurrences)
Last logged: 21:04:38

Unexpected error fetching None data: can only concatenate str (not "int") to str
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/shopping_list_with_grocy/init.py", line 189, in async_update_data
return await self.api.retrieve_data()
File "/config/custom_components/shopping_list_with_grocy/apis/shopping_list_with_grocy.py", line 553, in retrieve_data
await self.parse_products(self.final_data)
File "/config/custom_components/shopping_list_with_grocy/apis/shopping_list_with_grocy.py", line 233, in parse_products
shopping_lists["list
" + shopping_list_id] = {
TypeError: can only concatenate str (not "int") to str

@Anrolosia
Copy link
Owner

You have to play with the list_x_qty attribute:
image

If a product is in a list, no matter which one, it will have dynamicaly 3 new attributes, list_x_qty, list_x_note and list_x_shop_list_id

You can do you own shopping list dashboard, and have an intermediary window/popup when you want to add a product to specify on which list, then you call the service with the list_id filled :)

@anha7196
Copy link
Author

It seems the list_x_qty attribute is not present for me, i guess because of the "str not int" error at startup i wrote about in the last post.

This is the attributes from a sensor.shopping_list_with_grocy_ item in my installation (removed the image stuff":

product_id: 110 id_in_shopping_list: 2336 qty_in_shopping_list: 150 qty_in_stock: 0 product_image: topic: homeassistant/sensor/shopping_list_with_grocy_product_110/state note: location: Kylskåp group: Charkuterier icon: mdi:cart friendly_name: Leverpastej

@Anrolosia
Copy link
Owner

@anha7196 I'm curious, what is the entity_id of that product?? Because you shouldn't have id_in_shopping_list anymore... Is there a _v1_ in your entity_id?
Also, with v0.7.1, I added a cast to str just in case, so if you're uptodate, you shouldn't have this error anymore

@anha7196
Copy link
Author

anha7196 commented Jun 18, 2023

Yes, youŕe right! There is a _v1_ one with the new list_X attributes, and one without _v1_ with the id_in_shopping_list attribute.

So it is expected behavior to have the old products as sensors still?

@Anrolosia
Copy link
Owner

It was specified in the update that having products in double might be expected, in that case you have to hit the refresh service several times, or just delete the old sensor in Homeassistant

@anha7196
Copy link
Author

Ok, sorry for missing that. Refresh service seems to be dong nothing after many tries, so Iĺl have to delete manually.

I've made list for only my groceries now, works great! Thanks for the help!

@Anrolosia
Copy link
Owner

No worries! I'm glad it works now
I'll close that ticket then, have a great one!

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

No branches or pull requests

2 participants