Open nickc122 opened 3 years ago
Bump! Not just that, but trying to contribute additional information: I (kind of) remember that Our Groceries used to maintain the original category of an item if it has been on a list previously, and then just crossed out.
I can't pin down the exact time when that behaviour changed, but it might have been around the time when Our Groceries messed with the categories. At some time, they insisted to auto-suggest their own categories, and later, they made changes so that feature could be turned off again (again, just how I remember it).
I'd be willing to put some research into the API, but I couldn't even find a point to start at - is there a documentation available?
the underlying our groceries api does support categories it just needs to be added to this integration and card add_item_to_list(self, list_id, value, category="uncategorized", auto_category=False):
I modified line 241 in the init.py on my ha system from await self._og.add_item_to_list(internal_id, item, None) to await self._og.add_item_to_list(internal_id, item, None, True, None) to enable the auto_category and now the items come in the correct custom made category.
However I would like to make this configurable by adding an optional item in the config. I am willing to make a PR for it, but I need some tips on how to do that as I am not familiar with the HA internals.
What would you suggest? As far as I can see the config info is not available in the OurGroceriesServices. Also the og variable does not have room for adding this. The only solution I see is to expand the OurGroceriesServices init function to accept an additional variable. To either control the auto_category directly or a sort of config variable array for future items to be add.
Would you be willing to accept such a PR?
Adding on, I tested the solution by @gisteren and it worked perfectly.
Is it possible or would it be possible to include an OurGroceries category in my automations from Home Assistant? I initially assumed it wouldn't be an issue as OurGroceries typically maintains the category after you mark things off, but for some reason when things are added through HA they appear on the list without a category. Is there a way I could specify the category in my automations/scripts?