Anrolosia / Shopping-List-with-Grocy

A Shopping list integration with Grocy for Home Assistant
MIT License
41 stars 1 forks source link

Separate different grocy shopping lists? #21

Closed anha7196 closed 1 year ago

anha7196 commented 1 year ago

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 commented 1 year ago

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

anha7196 commented 1 year ago

Great! Looking forward to it!

Anrolosia commented 1 year ago

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 commented 1 year ago

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 shoppinglists["list" + shopping_list_id] = { TypeError: can only concatenate str (not "int") to str

Anrolosia commented 1 year ago

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 commented 1 year ago

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_withgrocy 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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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