Anrolosia / Shopping-List-with-Grocy

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

Custom user fields #28

Closed yordanov-alexandar closed 1 year ago

yordanov-alexandar commented 1 year ago

Add custom user fields to the product sensors. I have a lot of products in my Grocy and I am using the example UI(with changes). But with this many products it's hard to find the one that I need so I wanted to make a custom sort to order the products with the most used ones on top. For this I made a custom field in Grocy but it's not shown in the individual product sensor so I can't sort by it. Please add the custom fields to the product sensor Thank you

Anrolosia commented 1 year ago

Hello!

Could you provide an example in Grocy on your custom field? And you'd like that field to be able in card configuration to specify sort, correct?

Thanks

yordanov-alexandar commented 1 year ago

In Grocy -> Manage master data -> Userfields I have added a userfield with Entity: products, Name: customsort, Caption: Custom sort, Type: Number(decimal) and Show as column in tables: checked After that I have a new field in the edit product dialog in which I enter some integer depending on how frequently I use this product Yes I would like that field to be able to be specified as a sort in card configuration so I can have my most frequently used products on top. The name of the field is of course not important and if you want to standardize a name and map only that name in the sensor (to avoid performance problems with many products and many custom fields) that would also work. Thank you

Anrolosia commented 1 year ago

Got it, thanks, I'll work on that :)

Anrolosia commented 1 year ago

I created version 0.10.0 to integrate that, let me know if it works as intended on your side :) https://github.com/Anrolosia/Shopping-List-with-Grocy#custom-products-userfields

yordanov-alexandar commented 1 year ago

It's working great :) Thank you You might want to change the example to

sort:
  method: attribute
  attribute: userfields:customsort
  numeric: true 

to make sure the field is treated as a number and sorted correctly - in the example the field in Grocy is type Number(decimal) so for consistency the sort field should be treated as a number too.

Anrolosia commented 1 year ago

You're definitely right! I updated the documentaton. Happy to know it's working, I will close the ticket :) Happy grocery!